Filters - Manipulate Text Files

The FILTER Program

The FILTER program performs various manipulations on the contents of a specified text file. The examples below illustrate the different functions that the program can perform, such as finding and replacing all instances of a specific character, changing the character encoding (e.g., from ASCII to Unicode) and reversing the direction of text in the file. An explanation of the parameters that are used with this program appears beneath these examples.

  • FILTER -replace <Oldstring> <Newstring> <Oldstring> <Newstring> [Input Output] — replaces the specified string or strings in the input file and outputs the result to the output file.
  • FILTER [-r] <Fromchar> <Tochar> <Targetchar>[Input Output] [-M Msgfile] — converts each character in the input file that falls within a designated range of ASCII values (e.g., all uppercase letters from A to Z) to a new character, using the following formula:
    new character = original character + (Targetchar – Fromchar).
    The input file should always be in ANSI format. Output is also in ANSI.

Example: The following command iterates through all characters in the input file that fall within the designated range (all uppercase letters from A to Z) and adds 32 to the ASCII valu e of these characters, thereby converting them to the corresponding lowercase letter:


You can also use this option to convert a tab-delimited file into a comma-delimited file (where '09' represents the ASCII value of the tab character):

EXECUTE FILTER '09', '09', ',', :INPUT, :OUTPUT;

FILTER parameters

  • '-r' — Use this option when you want the FILTER program to reverse the order of characters in the file (e.g., instead of 'abcd' you receive 'dcba').
  • Input, Output — The input and output files to which the FILTER program refers.
  • '-M', 'Msgfile' — Use this option when you want the FILTER program to record error messages in the designated file.

Special Filters

  • FILTER ‘-replacef’, ‘[string]’, :FILESTR, [Input Output] — replace the specified string in the input file with the string contents of another file FILESTR. Useful for when you need to insert a string longer than the 127 limit of Priority variables into a file.

Encoding Filters

  • FILTER -unicode2ascii [Input Output] [-M Msgfile] — converts the input file from Unicode to ASCII.
  • FILTER -ascii2unicode [Input Output] [-M Msgfile] — converts the input file from ASCII to Unicode.
  • FILTER -unicode2utf8 [Input Output] — converts a UTF-16 file to UTF-8.
  • FILTER -utf82unicode [Input Output] — converts a UTF-8 file to UTF-16.
  • FILTER -ofx2xml [Input Output] — converts an ofx file into a regular XML file that can be read with XMLPARSE.

File Formatting

  • FILTER -addcr [Input Output] — When using an SQL query to export data from Priority tables, the '\n' (new line) character is added automatically to the end of each line. Use this option to add the '\r' (carriage return) character, as well, throughout the file (so that each line ends with the characters '\r\n').
  • FILTER -trim [Input Output] — trims blank spaces at the beginning and end of each line in input file; also removes CR (carriage return) at the end of the line.
  • FILTER -delnl [Input Output] — Files generated by Priority generally end with an empty line with a new line (LF) character. This may interfere with external interfaces that expect files to end differently. This filter deletes the last empty line in a file.


  • FILTER -base64 [Input Output] — encodes a file into base64.
  • FILTER -unbase64 [Input Output] — decodes a file from base64. The input file must be in Unicode format.


    :_PDF = '../../f.pdf';
    :_PDF_B = '../../f_base64.txt';
    :_PDF2 = '../../f_new.pdf';
    EXECUTE FILTER '-unbase64', :_PDF_B, :_PDF2, SQL.TMPFILE;
  • FILTER ‘-replacestrbase64’, [Input, Output],’[stringToReplace]’, fileToConvert, SQL.TMPFILE — replaces the specified string in the input file with the result of converting another file to base64. Useful for inserting base64 data into JSON based requests.