The FILTERLINES function applies a filter expression that you create to each line of a multiline text expression.
TEXT or NTEXT
This function accepts TEXT values and NTEXT values as arguments. The data type of the return value depends on the data type of the values specified for the arguments:
When all arguments are TEXT values, the return value is TEXT.
When all arguments are NTEXT values, the return value is NTEXT.
When the arguments include both TEXT and NTEXT values, the function converts all TEXT values to NTEXT before performing the function operation, and the return value is NTEXT.
A multiline text expression whose lines should be modified according to filter-expression.
An expression to be applied as a filter to each line of source-expression. The terms of the filter expression dictate the processing that FILTERLINES performs on each line of the source expression.
The filter expression may produce NA
, which means that there is no line in the resulting text expression corresponding to the current line of the source expression.
You can use the keyword VALUE in your filter expression to represent the current line of the source expression.
FILTERLINES returns a text expression composed of the lines that result from the action of the filter expression on each line of the source expression. The filter expression may return multiline text for any or all of the input source lines. None of these lines are acted on again by the filter expression.
Example 7-94 Removing Extension From File Names
The following example shows how FILTERLINES could be used on a list of file names to produce a list of those same file names without extensions.
With a multiline text variable named filelist
that evaluates to
myfile1.txt file2.txt myfile3 file4.txt
the statement
SHOW FILTERLINES(FILELIST - IF FINDCHARS(VALUE '.') GT 0 - THEN EXTCHARS(VALUE 1 FINDCHARS(VALUE '.') -1) - ELSE VALUE)
produces the following output.
myfile1 file2 myfile3 file4