The next eight forms of the source part copy characters from the source to the destination until a source character fails or passes the specified test. The number of characters copied can also be limited by an optional count part. For more information on the use of these Boolean conditions, refer to SCAN Statement.
In the source parts containing a condition of either of the following forms the source characters are tested against bits [7:8], [5:6], or [3:4] of the arithmetic expression, depending on the character size of the source:
WHILE <relational operator> <arithmetic expression> UNTIL <relational operator> <arithmetic expression>
In all cases, the stack-source-pointer is left pointing to the character that failed or passed the test.
The count part consists of an arithmetic expression and, optionally, a residual count. The value of the arithmetic expression specifies the maximum number of characters to be copied. The residual count, when it appears, is a simple variable in which is stored the difference between the value of the arithmetic expression and the number of source-part characters copied.
<source> WHILE <relational operator> <arithmetic expression>
The stack-source-pointer is initialized to the source pointer. Characters are then copied from the source to the destination as long as source characters pass the test.
A paged (segmented) array error fault could occur at run time if all of the following conditions occur:
-
The stack-destination-pointer references the first character beyond the end of the destination array.
-
The stack-source-pointer references the first character to fail the test.
-
The stack-integer-counter is nonzero.
Example of a <source> WHILE <relational operator> <arithmetic expression> Form
REPLACE P BY Q WHILE NEQ " "
Q = "LONG STRING"
P = "LONG"
<source> UNTIL <relational operator> <arithmetic expression>
The stack-source-pointer is initialized to the source pointer. Characters are then copied from the source to the destination until a source character passes the test.
A paged (segmented) array error fault could occur at run time if all of the following conditions occur:
-
The stack-destination-pointer references the first character beyond the end of the destination array.
-
The stack-source-pointer references the first character to pass the test.
-
The stack-integer-counter is nonzero.
Example of a <source> UNTIL <relational operator> <arithmetic expression> Form
REPLACE P BY Q UNTIL = "."
Q = "FILE/TITLE ON PACK.XXX"
P = "FILE/TITLE ON PACK"
<source> WHILE IN <truth set table>
The stack-source-pointer is initialized to the source pointer. Characters are then copied from the source to the destination as long as the source characters are members of the truth set. For further information on truth sets, see TRUTHSET Declaration.
Example of a <source> WHILE IN <truth set table> Form
REPLACE P BY Q WHILE IN ALPHA8
Q = "ABCD1234.56"
P = "ABCD1234"
<source> UNTIL IN <truth set table>
The stack-source-pointer is initialized to the source pointer. Characters are then copied from the source to the destination until a source character is encountered that is a member of the truth set. For further information on truth sets, see TRUTHSET Declaration.
Example of a <source> UNTIL IN <truth set table> Form
REPLACE P BY Q UNTIL IN ALPHA8
Q = ", *,$1234"
P = ", *,$"
<source> FOR <count part> WHILE <relational operator> <arithmetic expression>
The stack-source-pointer is initialized to the source pointer. The stack-integer-counter is initialized to the value of the arithmetic expression in the count part. Characters are then copied from the source to the destination and the stack-integer-counter is decremented for each character copied as long as the stack-integer-counter is not zero and the source characters pass the test.
A paged (segmented) array error fault could occur at run time if all of the following conditions occur:
-
The stack-destination-pointer references the first character beyond the end of the destination array.
-
The stack-source-pointer references the first character to fail the test.
-
The stack-integer-counter is nonzero.
Example of a <source> FOR <count part> WHILE <relational operator><arithmetic expression> Form
REPLACE P BY Q FOR N:11 WHILE NEQ " "
Q = "LONG STRING"
P = "LONG" (and N = 7)
<source> FOR <count part> UNTIL <relational operator> <arithmetic expression>
The stack-source-pointer is initialized to the source pointer. The stack-integer-counter is initialized to the value of the arithmetic expression in the count part. Characters are then copied from the source to the destination and the stack-integer-counter is decremented for each character copied until either the stack-integer-counter is zero or a source character passes the test.
A paged (segmented) array error fault could occur at run time if all of the following conditions occur:
-
The stack-destination-pointer references the first character beyond the end of the destination array.
-
The stack-source-pointer references the first character to pass the test.
-
The stack-integer-counter is nonzero.
Example of a <source> FOR <count part> UNTIL <relational operator> <arithmetic expression> Form
REPLACE P BY Q FOR N:22 UNTIL = "."
Q = "FILE/TITLE ON PACK.XXX"
P = "FILE/TITLE ON PACK" (and N = 4)
<source> FOR <count part> WHILE IN <truth set table>
The stack-source-pointer is initialized to the source pointer. The stack-integer-counter is initialized to the value of the arithmetic expression in the count part. Characters are then copied from the source to the destination and the stack-integer-counter is decremented for each character copied as long as the stack-integer-counter is not zero and the source characters are members of the truth set. For further information on truth sets, see TRUTHSET Declaration.
Example of a <source> FOR <count part> WHILE IN <truth set table> Form
REPLACE P BY Q FOR N:11 WHILE IN ALPHA8
Q = "ABCD1234.56"
P = "ABCD1234" (and N = 3)
<source> FOR <count part> UNTIL IN <truth set table>
The stack-source-pointer is initialized to the source pointer. The stack-integer-counter is initialized to the value of the arithmetic expression in the count part. Characters are then copied from the source to the destination and the stack-integer-counter is decremented for each character copied until either the stack-integer-counter is zero or a source character is a member of the truth set. For further information on truth sets, see TRUTHSET Declaration.
Example of a <source> FOR <count part> UNTIL IN <truth set table> Form
REPLACE P BY Q FOR N:10 UNTIL IN ALPHA8
Q = ", *,$1234"
P = ", *,$" (and N = 4)

