Previous Topic: Compare Screen Data with a StringNext Topic: Working With CA TPX


Search a String for Another String

You can search a string for another string with the SCAN command. For example, the following statement determines if the string contained in the variable &USERID contains the string ADMIN.

SCAN '&USERID','ADMIN'

Only two condition codes are valid SCAN results:

EQ

Indicates that the string is present in the string that was searched. The variable &LOC is set to the position of the string found within the string that was search.

NE

Indicates that the string is not present in the string that was searched.

The variable &LOC expresses the position as the number of characters from the beginning of the string being searched. For example the following SCAN statement sets &LOC to 3:

SCAN 'ENTERDATA','TER'