The module markfilt.e provides the procedure filter_selection for filtering selected text. Define a global procedure that accepts a string and returns a string. Then pass the name of the procedure to the filter_selection procedure.
The following batch program converts the marked text into hexadecimal ASCII codes. Each hexadecimal ASCII code is separated by a comma. One possible use of this function could be to convert a binary font file into hexadecimal ASCII codes to be compiled into a C program.
#include "slick.sh"
_str hex_filt(string);
defmain()
{
if (_select_type()=="" ) {
message(get_message(TEXT_NOT_SELECTED_RC));
return(TEXT_NOT_SELECTED_RC);
}
// Underscores must be converted to dashes.
return(filter_selection(hex_filt));
}
_str hex_filt(string)
{
line="";
for (i =1;i<=length(string);++i) {
line=line:+dec2hex(_asc(substr(string,i,1))):+",";
}
return(line);
}