CHOP
NCHAR
The CHOP instruction moves one string to another, deleting all trailing spaces in the process. The instruction uses the following format:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
source
Required. A previously defined Character String Variable or National Character String Variable containing the string that is moved.
sep
Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.
dest
Optional. A previously defined Character String Variable or National Character String Variable that receives the source string.
Flags Affected: EOS
Note the following:
The transfer from the {source} operand 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 when two operands are specified.
The transfer into {dest} begins at the first physical character. The Form Pointer of {dest} is set to one (1) and the Length Pointer to the last character moved.
If the {dest} is too small for the transfer, the EOS Condition Flag is set.
Trailing spaces in the {source} string are not moved.
If {source} is null or all blanks, the Form Pointer of {dest} is set to zero (CLEARed).
If {dest} is not specified, the {source} variable is modified.
Enhanced ARRAY processing is supported. If an array is specified (without an index), the CHOP instruction is performed on each element within the array.
Examples when CHOP instruction uses LEADING and/or TRAILING keywords.
|
$ON |
FORM |
"1" |
|
$OF |
FORM |
"0" |
|
dIn |
DIM |
50 |
|
dOut |
DIM |
50 |
|
. |
|
|
|
.Delete leading spaces only | ||
|
. |
|
|
|
|
MOVE |
" ABCD ", dIn |
|
|
CHOP |
dIn, dOut, LEADING=$ON,TRAILING=$OFF |
|
. |
|
|
|
.Delete both leading and trailing spaces. | ||
|
.The CHOP deletes trailing spaces by default. | ||
|
. |
|
|
|
|
MOVE |
" NEXT ", dIn |
|
|
CHOP |
dIn, dOut, LEADING=1 |
|
. |
|
|
|
.Delete leading and trailing spaces with operand | ||
|
. |
|
|
|
|
MOVE |
" FIRST ", dIn |
|
|
CHOP |
dIn, TRAILING=1, LEADING=1 |
See Also: Example Code, Character String Instructions
![]() |