The EXTRACT function is used to access a specified attribute, value, or subvalue from a dynamic array string.
Format
EXTRACT(string , attr# [, value# [, subval#]]) string < attr# [, value# [, subval#]] > |
Parameter(s)
string |
Dynamic array string. |
attr# |
An expression evaluating to the attribute number. |
value# |
An expression evaluating to the value number. If value# is omitted, the entire contents of the attribute is returned. |
subval# |
An expression evaluating to the subvalue number. If subval# is omitted, the entire contents of the value is returned. |
Description
The EXTRACT function returns a specified attribute, value, or subvalue of a string. There are two forms to the EXTRACT function: the first uses the keyword EXTRACT, and the second uses angle brackets.
If an attribute, value, or subvalue expression evaluates to a noninteger value, it is truncated to an integer value. If the attribute, value, and subvalue expressions each evaluate to a value less than 1, the null string is returned.
Example
To assign the variable ZIP to Attribute 6 of the string array ADDRESS, the code would read:
ZIP = EXTRACT(ADDRESS, 6) |
or
ZIP = ADDRESS < 6 > |
In the next application, a program prints the billing information for a customer. The first and second attributes of the record CUST.REC contain the customer’s name, and the sixth, seventh, and eighth attributes contain the customer’s billing information.
EQUATE BLANK TO " ", NIL TO "" . . . NAME = CUST.REC< 1 > : BLANK NAME := CUST.REC< 2 > PRINT NAME PRINT "CREDIT CARD: " , CUST.REC< 6 > PRINT "ACCT. NO. :" , CUST.REC< 7 > PRINT "EXPIRES:" , OCONV( CUST.REC< 8 >, "D" ) |
See Also