Compaq AAQ2G1FTK Marine Radio User Manual


 
Using the STRING, UNSTRING, and INSPECT Statements
5.1 Concatenating Data Using the STRING Statement
5.1.5 Common STRING Statement Errors
The following are common errors made when writing STRING statements:
Using the word TO instead of INTO
Failing to include the DELIMITED BY SIZE phrase
Failing to initialize the pointer
Initializing the pointer to 0 instead of 1
Permitting the pointer to get out of range (negative or larger than the size of
the receiving field)
Failing to provide for space-filling of the receiving item when it is desirable
Using the pointer as a subscript without fully understanding subscript
evaluation
5.2 Separating Data Using the UNSTRING Statement
The UNSTRING statement disperses the contents of a single sending item into
one or more receiving items.
The statement has many forms; the simplest is equivalent in function to a
nonnumeric MOVE statement. Consider the following example:
UNSTRING FIELD1 INTO FIELD2.
Regardless of the relative sizes of the two items, the sample statement is
equivalent to the following MOVE statement:
MOVE FIELD1 TO FIELD2.
The sending item (FIELD1) can be either ( 1 ) a group item, or ( 2 ) an
alphanumeric or alphanumeric edited elementary item. The receiving item
(FIELD2) can be alphabetic, alphanumeric, or numeric, but it cannot specify any
type of editing.
If the receiving item is numeric, it must be DISPLAY usage. The PICTURE
character-string of a numeric receiving item can contain any of the legal numeric
description characters except P and the editing characters. The UNSTRING
statement moves the sending item to the numeric receiving item as if the sending
item had been described as an unsigned integer. It automatically truncates or
zero-fills as required.
If the receiving item is not numeric, the statement follows the rules for
elementary nonnumeric MOVE statements. It left-justifies the data in the
receiving item, truncating or space-filling as required. If the data description of
the receiving item contains a JUSTIFIED clause, the compiler right-justifies the
data, truncating or space-filling to the left as required.
5.2.1 Multiple Receiving Items
The UNSTRING statement can disperse one sending item into several receiving
items. Consider the following example of the UNSTRING statement written with
multiple receiving items:
UNSTRING FIELD1 INTO FIELD2A FIELD2B FIELD2C.
5–6 Using the STRING, UNSTRING, and INSPECT Statements