TRANS Function
Extracts data from a file.
This function is provided for compatibility with other MultiValue systems.
Syntax
TRANS({DICT }fileSpec, itemId, attrNo{, actionCode})
XLATE({DICT }fileSpec, itemId, attrNo{, actionCode})
Syntax Elements
DICT Specifies that the dictionary of the specified file should be used instead of the data section. This keyword can also be in lower case (dict).
fileSpec The name of file from which to extract the data, in the following format:
{/account/}filename{,data-section-name}
If both DICT and data-section-name are specified, data-section-name is ignored.
itemId The item-Id of the required source file item.
attrNo The number of the required attribute in the specified item.
-
If attrNo evaluates to 0, the item-id is used.
-
If attrNo is null or omitted, no data is extracted.
actionCode An expression that evaluates to the following:
errorOp{[valueNo||:delimiter]}
errorOp The action to take if the specified item does not exist or the specified attribute is null. One of the following:
C Return itemId.
V Display an error message and return null.
XReturn null.
valueNo One of the following:
-
A value number: TRANS or XLATE returns that value from the specified attribute; if omitted, the complete attribute is returned.
-
An asterisk (*): return the first value.
:delimiter Use delimiter to separate values and subvalues. If delimiter contains more than one character, only the first is used.
If actionCode is null the default is "X".
Return Value
The extracted data.
Comments
TRANS and XLATE return the same value as:
OCONV(itemId,"T{DICT }fileSpec;actionCode;;attrNo;")
See Also
OCONV function, Tfile conversion code.
Example
Assuming that the file TRANS.DATA contains the following item:
TRANS.ITEM
001 A
002 BAVMBBVMBC
003 CAVMCBASVMCBBSVMCBCVMCC
The following sets the variable ITEM to "BAVMBBVMBC":
ITEM = TRANS("TRANS.DATA", "TRANS.ITEM", 2)
and the following sets ITEM to the item-id, "TRANS.ITEM":
ITEM = TRANS("TRANS.DATA", "TRANS.ITEM", 4, "C")