RGET

Returns the value of a portion of a specified string. The value is converted to the specified format based on a specified conversion type.

Note: You can use the RGET function to parse records obtained from the LOOKUP or LOOKUPV functions or other sources. You should call the RGET function once for each variable to be extracted from a record.

Syntax

RGET(record,[type,start,number])

Arguments

Argument Description Default
record The string that contains the information to find and convert to a numeric value. None
[type] One of the following, to indicate how Enrichment is to read the data from record:

B—C—N—I—F—D—L—R—S—Extract number characters as a string beginning at start.

N
B Extract the binary pattern of the byte at start. Enrichment returns the 8-byte pattern with high-order bits first (10000000 = 128).
C Extract the numeric value of the byte at start. This value will be in the range 0 to 255.
N Extract the two-byte binary integer value beginning at start.
I Extract the four-byte binary integer value beginning at start.
F Extract the four-byte binary floating-point value beginning at start. Return the value to number significant digits. The value of number may not exceed 10.
D Extract the eight-byte binary floating-point value beginning at start. Return the value to number significant digits. The value of number may not exceed 10.
L Extract a number-digit packed decimal value starting at the left side of the byte at start.
R Extract a number-digit packed decimal value starting at the right side of the byte at .
S Extract number characters as a string beginning at start.
[start] The column number (greater than 0) in record at which the data to convert begins. 1
[number] The number (greater than 0) of characters, bytes, or digits to read. number is used in conjunction with a type of F, D, L, R, or S. For type of F or D, the value of number may not exceed 10. 1

Results

Result Description
Return The converted numeric value of the specified data.
%%RC One of the following:
0 No error.
1 start is larger than record. The return is 0.
2 record is not large enough to read the specified number of bytes. The return is 0.
3 The specified data is not in packed decimal format. The return is 0.
%%RM A null string ('').
%%RV Always set to 0.

Examples

The string below contains data that was written as follows:

  • 1-10 – Alpha Customer Number
  • 11-12 – INT2 Number of transactions
  • 13 BYTE Encoded option list
Function Call Return %%RC
RGET(%%record,N,11) 123 (for example) 0
RGET(%%record,B,13,7) 01100001 0
RGET(%%record,C,13,7) 97 0
RGET(%%record,D,10) 0 2