SQUEEZE
NCHAR
The SQUEEZE instruction moves the logical contents of a string variable, numeric variable, constant, or literal to another string variable while removing characters. The instruction uses the following format:
|
|
|
|
|
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
source
Required. A previously defined Character String Variable, National Character String Variable, Numeric Variable, Constant, or Literal whose Logical String is used.
dest
Required. A previously defined Character String Variable or National Character String Variable that receives the {source} value.
delete
Optional. A previously defined Character String Variable, National Character String Variable, Literal, or National Character String Literal indicating the characters to delete from the source string during the transfer.
chars
Optional. A previously defined Character String Variable, National Character String Variable, Literal or National Character String Literal indicating the characters to keep from the source string during the transfer.
Flags Affected: EOS
Note the following:
When {source} is a character variable, the transfer begins at the Form Pointed character and continues through the Length Pointed character (i.e., the Logical String) or until {dest} is full (whichever occurs first). The {source} operand remains unchanged unless {source} and {dest} are the same.
The transfer into {dest} begins at the first physical character. If any characters are transferred, the Form Pointer of {dest} is set to one (1) and the Length Pointer of {dest} is set to the last character moved. If no characters are transferred, the Form Pointer and Length Pointer of {dest} is set to zero (0).
If the {dest} is too small for the transfer, the EOS Condition Flag is set.
If {delete} is not specified or is a null variable, spaces are removed.
If {chars} is specified, it indicates characters to keep from the source string during the transfer. The KEEP option was added in version 9.0.
If {chars} is a Null String, spaces are the only characters kept when the {source} string data is transferred to the {dest} variable.
Example 1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 2 3 4 5 6 7 8 9 0 |
|
|
|
|
|
|
87654 |
|
| |||||
|
|
|
|
|
|
1 2 3 4 5 6 7 8 9 0 |
|
|
|
|
|
|
1234567890 |
No Condition Flags are set (all FALSE).
Example 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1X2 3 4 5 6 7 8 9 0X |
|
|
|
|
|
|
87654 |
|
| |||||
|
|
|
|
|
|
1X2 3 4 5 6 7 8 9 0X |
|
|
|
|
|
|
12 3 4 5 6 7 8 9 0 |
No Condition Flags are set (all FALSE).
Example 3:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1X2X3Y4Y5Y6Z7Z8Z9Z0Z |
|
|
|
|
|
|
87654 |
|
| |||||
|
|
|
|
|
|
1X2X3Y4Y5Y6Z7Z8Z9Z0Z |
|
|
|
|
|
|
1234567 |
The EOS Condition Flag is set since OUTPUT was too small to contain all the possible characters.
Example 4:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1234567890 |
|
| |||||
|
|
|
|
|
|
123456890 |
No Condition Flags are set (all FALSE).
Example 5:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 2 3 4 5 6 7 8 9 0 |
|
| |||||
|
|
|
|
|
|
37 |
No Condition Flags are set (all FALSE).
See Also: Character String Instructions
![]() |