TESTN

Figure 1. Syntax

1  TESTN ( name ,
1! 'EQ'
1 operator
2?  + , value
2?   VER
2  )

Can be used in FASTREXX condition expressions.

name
This is a 1-256 name that matches either a tally literal or a numeric variable. Variable name matching is not case sensitive. If the name is not found, a numeric variable is created with value of 0.
operator
The default is EQ or =. This function supports all the operators described for dynamic template and criteria edit. For details about the operators supported and their description, see:
value
The value or values entered must be valid in the context of the operator and the field which is being referenced. For example, only certain operators like CO (contains) allow multiple values. Numeric values should be entered when testing numeric fields, and so on.
  • Specifying hexadecimal strings. A hexadecimal string must be in the form 'hhhhhh'x. The value enclosed in quotation marks must be an even number of characters and contain valid hexadecimal characters (0–9, A–F).
  • Specifying binary strings. A binary string must be in the form 'nnnnnn'b. The value enclosed in quotation marks must be a combination of "0"s and "1"s.
  • Specifying character strings. For non-numeric types, the value should be enclosed in quotation marks.
  • Specify a variable by specifying &variable_name. A variable is substituted for the value if a matching character, numeric, or tally variable can be located. If a matching variable cannot be found, the string is treated as a literal value. If a numeric comparison is being performed, a character variable is converted to a number - if the conversion fails, the function returns a false result. If a numeric or tally variable is referenced in a character comparison, then the value is the number converted to its display form with leading zeros removed.
VER
Verify the field is composed only of characters specified in the value column.

Example 1

Count the number of records with A in the first byte and stop processing after 20.

IF FLD(1,1) = 'A' then
  SETN(COUNTA,'+1')

if TESTN(COUNTA,'>',20) then
     return "STOP IMMEDIATE"
   else
     return

Example 2

When the total of packed decimal field start at column 28 is greater than 100, stop processing

Note: In this case, allow File Manager to calculate the packed-decimal field length.
TALLY(28,P,'Total Sales')
  if TESTN('Total Sales',,'>',100) then
     return "STOP IMMEDIATE"
   else
     return