VAR_TM

Figure 1. Syntax

1  VAR_TM ( name ,
1! 1
1 start
2  ,
2  mask ,
2? ! 1 type
2  )

(Can be used in FASTREXX procedures.)

Note: Commas following the last specified argument can be omitted.
name
1–256 character variable identifier. Variable name matching is not case sensitive. If the name is not found, the function returns a false result.
start
Position, in bytes, in the variable at which to start testing. The length of the field is defined by the mask (mask). Can be specified as:
Absolute position
Must be a positive integer. Default value is 1. If start is greater than the current length of the variable, the function has no effect.
Relative to variable position
Can be specified as IPx or INx, or as Px or Nx, or as OPx or ONx. If this resolves to a value of less than or equal to zero, the function results in an error. If this resolves to a value that is greater than the current length of the variable, the function has no effect.
mask
A bit string determining which bits to test in the field. The length of mask defines the length of the input field. This field defines a bit string mapping used to test the specified bits in the variable. You can use the bit string, hex string or character string formats to define this field, Therefore, '0100 0000'b, '40'x, and ' ' are all legitimate and equivalent ways of defining a mask to test the second bit of a one-byte field.
type
The type of test:
1
VAR_TM returns True (1) if all the bits that are on in the mask are on in the variable field. This is the default value.
0
VAR_TM returns True (1) if all the bits that are on in the mask are off in the variable field.
M
VAR_TM returns True (1) if at least one of the bits that are on in the mask is on in the variable, and at least one is off.
N
VAR_TM returns True (1) if at least one of the bits that are on in the mask is off in the variable field.

Example 1

Test the third byte of the variable and, if the low order bit is set, overlay a hex FF into the second byte of the output record.

If VAR_TM(3,'01'x) Then Do
  OVLY_OUT('ff'x,2,1)
  Return
End
Return 'DROP'

Example 2

Test the third byte of the variable and, if some of the three high order bits are set, and some are not, overlay the contents of the second byte of that record with a hex 04.

If VAR_TM(3,'11100000'b,M) Then Do
  OVLY_OUT('04'x,2,1)
  

Example 3

Test the current position of the variable and, if the low order bit is set, overlay a hex FF into the byte prior to this location in the output record.

If VAR_TM(P0,'01'x) Then Do
  OVLY_OUT('ff'x,IN1,1)
  Return
End
Return 'DROP'