The ITYPE() function executes a compiled I or C-type dictionary record or an A or S-type with a correlative.
The ITYPE() function evaluates expression compiled as part of the given I-type dictionary record and returns its result. C-type and A/S-type records with correlatives can also be evaluated using this function.
The working environment for the ITYPE() function must be established by setting @ID to the key of the record being processed and @RECORD to the record data if these are used by the expression. These variables are also used internally by the query processor to store the id and data for the current record. If the expression evaluated by the ITYPE() function calls a subroutine that modifies these variables, the original values must be saved and reinstated if the dictionary item is to be usable within the query processor.
The dictionary record must have been compiled before the ITYPE() function is used.
If the byte ordering of the object code in the itype variable is not the same as that of the machine on which it is being executed, it will be converted automatically and the itype variable will be modified to contain the converted object code so that a subsequent call to the ITYPE() function will not repeat the conversion.
The ITYPE() function can also be used to evaluate D-type items and A or S type items that do not include a correlative. Although the performance of this use of the function will be significantly lower than simple field extraction in the calling program, it may allow some programs that do not require best performance to adopt a generalised interface for all dictionary record types that define data item values.
READ IREC FROM DICT.FILE, "AGE" THEN
@RECORD = REC
AGE = ITYPE(IREC)
This program fragment reads dictionary record "AGE" to IREC. This might, perhaps, be an I-type to calculate a person's age from their date of birth. The @RECORD variable is set to the data to be processed and the ITYPE() function is used to execute the I-type.