STRING chp 16 Purpose puts together separate strings


- Slides: 2

STRING (chp. 16) Purpose: puts together separate “strings” into one “string” Syntax Definition: STRING { {identifier-1 | literal-1} DELIMITED BY {identifier-2 | literal-2 | SIZE} } … INTO identifier-3 [END-STRING] RULES: For 2 participation points, write a program to: City pic x(10). State pic xx. Zip pic x(10). Zip format is xxxxx-xxxx Display: City, ST xxxxx with only “, b” between the City and ST (i. e. No extra spaces allowed) The DELIMITED BY clause is required. It can indicate: SIZE – the entire sending field is transmitted Literal – the transfer of data is terminated when the specified literal is encountered; the literal itself is not moved Identifier – the transfer of data is terminated when the contents of the identifier is encountered The receiving field must be an elementary data item with no editing symbols. All literals must be non-numeric. The STRING statement moves data from left to right (like alphanumeric moves) but a STRING does NOT pad with blanks. Only the identifier-3 memory location will change upon execution of this statement. If the “delimited by” identifier or literal is not found, the entire string is returned.

UNSTRING (chp. 16) Purpose: Syntax Definition: UNSTRING identifier-1 DELIMITED BY {identifier-2 | literal-1} [ OR {identifier-3 | literal-2} ] … INTO identifier-4… [END-UNSTRING] For 4 participation points, use an OR example not given in class. Combine in a program with previous STRING participation points. RULES: The sending field must be nonnumeric The receiving field(s) may be numeric or nonnumeric. Each literal must be non-numeric. Does not retain previous information in identifier-4.