This format of the @SET statement is used to assign values to integer variables. This value may be the result of an expression, may be obtained by converting a printable number or the content of a line number variable into an integer value, or may take the form of a line length or the binary value of a string.
Operation | Operands | F mode, L mode |
@SET | ivar={ intex | lvar | LENGTH line | LENGTH svarex | SUBSTR string | STRING string [,CODE=name] } |
ivar intex | Integer variable ( Integer expression. If the maximum negative or positive value ( |
lvar | Line number variable ( |
LENGTH line | Line number of a line whose length is to be assigned as a value to the |
LENGTH svarex | String variable whose length is to be assigned as a value to the integer variable. |
SUBSTR string | String specifying an integer value to be assigned to the integer variable. Any plus or minus sign present in the string is taken into account during If the string is not an integer value then the statement is rejected with the error message |
STRING string | String. The binary value of the first 4 bytes of the string is assigned to the |
name | Character set in which the string is to be interpreted. The string is converted If the operand is not specified then the character set of the specified string |
In this statement, the statement name may be omitted entirely. In F mode, it is also permissible to omit the statement symbol.
Example
1. @SET #I0 = SUBSTR '123' --------------------------------------- (1) 1. @SET #L0 = 1.01 ----------------------------------------------- (2) 1. @SET #I1 = #L0 ------------------------------------------------ (3) 1. @CREATE 1 'AB' ------------------------------------------------ (4) 1. @SET #I2 = LENGTH 1 ------------------------------------------- (5) 1. @SET #I3 = 2124 + #I0 + #I1 - #I2 ----------------------------- (6) 1. @SET #I4 = STRING '123' --------------------------------------- (7) 1. @SET #I5 = STRING 'A',CODE=UTF16 ------------------------------ (8) 1. @STATUS = I --------------------------------------------------- (9) #I00= 0000000123 #I01= 0000010100 #I02= 0000000002 #I03= 0000012345 #I04= 0015856371 #I05= 0000000065 #I06= 0000000000 #I07= 0000000000 #I08= 0000000000 #I09= 0000000000 #I10= 0000000000 #I11= 0000000000 #I12= 0000000000 #I13= 0000000000 #I14= 0000000000 #I15= 0000000000 #I16= 0000000000 #I17= 0000000000 #I18= 0000000000 #I19= 0000000000 #I20= 0000000000
(1) | The value 123 is assigned to the integer variable #I0 . |
(2) | The value 0001.0100 is assigned to the line number variable #L0 . |
(3) | The value 10100 , line number 1.01 * 10000 , is assigned to the integer variable #I1 . |
(4) | Line 1 is created with the content AB . |
(5) | The value 2 , the length of line 1, is assigned to the integer variable #I2 . |
(6) | The value of the expression is assigned to the integer variable #I3 . |
(7) | The value X'00F1F2F3' = 15856371 is assigned to the integer variable #I4 . |
(8) | The value which corresponds to the Unicode code position |
(9) | The content of the integer variable is output. |