


The STRING statement concatenates data items.
STRING { {source} ... DELIMITED BY {delimiter} } ...
{SIZE }
INTO destination
[ WITH POINTER ptr-var ]
[ ON OVERFLOW statement-1 ]
[ NOT ON OVERFLOW statement-2 ]
[ END-STRING ]
Syntax Rules
1. Source and delimiter are nonnumeric literals or data items with USAGE DISPLAY. The "ALL literal" construct may not be used.
2. Destination is a data item with USAGE DISPLAY. It may not be JUSTIFIED or edited. Destination may not be reference modified.
3. Ptr-var is an integer numeric data item.
4. Statement-1 and statement-2 are imperative statements.
5. The size of ptr-var must allow it to contain a value one greater than the size of destination.
General Rules
1. The STRING statement concatenates the source values and places the result in destination. Up to 50 source items are allowed.
2. The STRING statement moves characters from source to destination according to the rules for alphanumeric to alphanumeric moves. However, no space filling occurs.
3. The contents of each source item are moved to destination in the order they appear. Data is moved from the left, character by character, until the end of source is reached. The end point of each source item is determined by the DELIMITED phrase according to the following rules:
a) Transfer stops when the end of source is reached.
b) Transfer stops when the end of destination is reached.
c) If delimiter is specified, transfer stops when the characters specified by delimiter are found in source. The delimiter is not included in the characters transferred.
d) If the SIZE option is used, transfer ends only when the end of source or destination is reached.
e) When source or delimiter is a figurative constant, it represents a size of one character.
f) If source is a variable size item, the current size is used to determine the end of source. If the current size is zero characters, no transfer occurs for that source item.
4. When the POINTER phrase is specified, ptr-var must be set by the program to a value greater than zero before the STRING statement executes. The transfer to destination starts at the character position in destination indicated by ptr-var. The leftmost character of destination is position "1". If no POINTER phrase is used, an implied pointer is created and set to the value "1".
5. Ptr-var (or the implied pointer) is incremented by one for each character transferred to destination. The transfer to destination always occurs at the character position indicated by the current pointer value.
6. When the STRING statement ends, only those parts of destination referenced during execution change.
7. Before moving each character to destination, the STRING statement tests the value of ptr-var (or the implied pointer if ptr-var is not specified). If this value is less than one or greater than the size of destination, the overflow condition is set and the following happens:
a) No more data is transferred to destination.
b) If the ON OVERFLOW phrase is used, statement-1 executes.
c) The STRING statement ends.
8. If the NOT ON OVERFLOW phrase is specified, statement-2 executes after the STRING statement is finished if the overflow condition has not occurred (see general rule 7).
9. Subscripting for source and delimiter occurs just before the corresponding item is used.
10. Subscription for ptr-var and destination occurs just before the STRING statement executes.
More: