characterfilter
INPUT
,
OUTPUT
,
FILTER

The characterfilter statement scans and filters text on a character by character basis.


Parameters

This statement has three parameters:

input – is the text to be scanned and filtered.

output – the field or variable where the filtered text will be placed.

filter – is a formula that produces a text result. This formula will be calculated for each character in the input parameter. The result will be appended to the output field or variable. The result of this formula isn’t limited to a single character, but may be several characters or zero characters (“”). Within the formula you can use the import( function to retrieve the original character, or the seq( function to retrieve the position of the character within the text.


Description

The characterfilter statement scans text on a character by character basis. Rather than using a fixed processing method to filter the text, it allows the programmer to supply a formula that is used over and over again to filter each individual character of the text. As it scans the input text, it builds a new text field or variable. The contents of the new text is based on the result of the formula which is applied to each character of the original text. The formula can use the import( function to retrieve the original character, or the seq( function to retrieve the position of the character within the text.

Let’s review some examples that illustrate the operation of the characterfilter statement. This example converts a string of characters into a comma separated array.

local commaArray
characterfilter "abcd",commaArray,import()+","

After this procedure has run, the commaArray variable will contain this text:

a,b,c,d,

This example converts text into a set of hex digits.

local digits 
characterfilter "abcd",digits,hexstr(asc(import()))[-2,-1]+" "

After this procedure has run, the digits variable will contain this text:

61 62 63 64

Note that characterfilter now also supports use with Unicode characters as shown in this example.

local ChrNum
characterfilter "a⏎b™c", ChrNum,asc(import())+" "

After this procedure is run, the ChrNum variable will contain this text:

97 9166 98 8482 99 

See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0. but now also supports Unicode characters.