![]() ![]() |
|
XLATEThe XLATE function will return the data value of a field, given the name of the file, the record key, the field number, and an action code.
COMMAND SYNTAXXLATE ([DICT] filename, key, field#, action.code)
SYNTAX ELEMENTSDICT is the literal string to be placed before the file name in the event it is desired to open the dictionary portion of the file, rather than the data portion. filename is a string containing the name of the file to be accessed. Note that it is the actual name of the file, and not a file unit variable. This function requires the file name, regardless of whether or not the file has been opened to a file unit variable. key is an expression that evaluates to the record key, or item ID, of the record from which data is to be accessed. field# is the field number to be retrieved from the record. action.code indicates what should happen if the field is null, or the if record is not found. This is a literal. The valid codes are:
NOTESIf the field being accessed is a dynamic array, XLATE will return the array with the delimiter characters lowered by 1. For example, multivalue marks (ASCII-253) are returned as subvalue marks (ASCII-252), and subvalue marks are returned as text marks (ASCII-251). If you supply -1 for field#, the entire record will be returned. The XLATE function is the same as the TRANS function.
EXAMPLES1) Retrieval of a simple field: Given a file called "VENDORS" containing a record with the record key of "12345" and which contains the value of "ABC Company" in field 1,
will display:
2) Retrieval of an array: Suppose field 6 of the VENDORS file contains a multivalued list of purchase order numbers, such as
and you use the XLATE function to retrieve it:
will display:
Notice that the backslashes (\) were substituted for brackets (]), indicating that the delimiter is now CHAR(252). 3) Retrieval of an entire dictionary item: Given a dictionary item called "VENDOR.NAME" with the following content
these statements
will display
|