SET TEMP
The SET TEMP statement copies the contents of a field to or from the selected predefined TEMP field. The statement identifies substrings of the selected predefined TEMP field and the field specified in the statement.
SET TEMP AT FOR
OF
(1)
(2) (3) (4) (5) (6) (7) (8) (9)
(6) Field start (constant/index) | |
(2) TEMP length (constant/index) |
|
(3) TEMP start (constant/index) |
|
(4) Length to copy (constant/index) |
(9) Field occurrence (constant/index) |
(5) Direction (FROM or INTO) |
|
The TEMP field to be used is specified by the length supplied; all predefined TEMP fields have the same characteristics except for their length. The user specifies which TEMP field is to be used by entering the appropriate length.
The TEMP length, starting character, and length to copy can be either predefined fields (A through Z or AI through ZI), or they can be specified as constant positive integer values. Note that the best performance can be obtained by specifying the TEMP starting length and length to copy as constants, or by using the integer AI through ZI fields as parameters.
The direction from/into indicates which field is the source and which field is the destination. If it specifies the FROM option, data is copied from the field specified in the statement to the selected predefined TEMP field. If the direction specifies the INTO option, data is copied from the selected predefined TEMP field into the field specified in the statement. This field must be alphanumeric.
The TEMP starting parameter identifies the starting position for the selected predefined TEMP field. Characters are copied to or from the selected predefined TEMP field beginning with this position. This can either be a constant or an index (predefined fields A through Z or AI through ZI). If this parameter is a fraction, its value is rounded to the nearest integer. (The contents of the actual predefined field, A through Z or AI through ZI, remain unchanged.)
The length parameter identifies the number of characters to be copied. This can either be a constant or an index. If this parameter is a fraction, its value is rounded to the nearest integer. (The contents of the actual predefined field, A through Z or AI through ZI, remain unchanged.) If, after rounding, the length parameter is greater than the maximum length available in the source field, the latter is used as the length parameter. This maximum length is determined by calculating the number of bytes that remain in the source field from its specified start position to the end of the field.
The field starting parameter determines the location in the field where copying begins. This can either be a constant or an index. If this parameter is a fraction, its value is rounded to the nearest integer. (The contents of the actual predefined field, A through Z or AI through ZI, remain unchanged.) The number of characters to copy is determined by the length parameter described above, and can be constrained by the length of the destination field. In other words, characters are copied up to the number specified by the length parameter, or until the destination field is filled, whichever comes first.
The justification type and pad character are ignored. The characters copied are always stored left justified in the destination field. If padding is required, the space character is used. Ending spaces are copied unchanged. The word-wrap option is ignored. No formatting takes place.
The INTO option is invalid for constants and for predefined fields that are defined to be non-modifiable. It is valid to use the selected predefined TEMP field also as the field specified in the statement. The copy performs the same as it would if the source field were a different field.
If, after rounding, the value of the TEMP starting parameter is less than 1, or greater than the length of the selected predefined TEMP field, a non-recoverable runtime error occurs.
If, after rounding, the value of the length parameter is less than 1, a non-recoverable runtime error occurs.
If, after rounding, the value of the field starting parameter is less than 1, or greater than the size of the field specified in the statement, a non-recoverable error occurs.
In the following example, SET TEMP is used to obtain characters 2, 3, and 4 of WORK CHECK.
SET TEMP 79 AT 001 FOR 003 FROM 002 OF TAP WORK CHECK
In this next example, the fifth and sixth characters of TEMP 80 are moved into the seventh and eighth character positions of WORK CHECK.
SET TEMP 80 AT 005 FOR 002 INTO 007 OF TAP WORK CHECK