Returns the results of an I-type calculation.
||A valid virtual attribute. Must be a compiled I-type in the dictionary opened as @DICT.
function evaluates an itype expression defined in a dictionary item against data in an MVBasic program and returns the result.
reads the dictionary item ITypeDictItem
from the file opened to the @DICT variable. It then evaluates the itype expression defined in attribute 2 of the dictionary item, using the data in @ID and @RECORD. Calculate also sets the @CONV, @FORMAT, and @HEADER system variables
to attributes 3, 5, and 4 of the dictionary item respectively. These can be used with the OCONV
functions to format the results of CALCULATE
Before using CALCULATE
you must open a file to the @DICT system variable, and assign values to @ID and @RECORD. If the itype expression uses other @variables (for example @FILE.NAME) then these need to be set as well.
CALCULATE and ITYPE Compared
function argument is a variable into which a dictionary item has already been read, or an itype expression assigned. The ITYPE
function allows on-the-fly creation of itype expressions
function argument must be the name of an existing dictionary item which will be read by the function.
The following example opens the Myfile file to the item variable, and the Myfile dictionary to the @DICT special variable. It then reads through the item variable by @ID, and uses CALCULATE
to calculate a total of the records in item. CALCULATE
also sets values for the @CONV and @FORMAT system variables used by the OCONV
OPEN 'Myfile' TO item ELSE STOP 201,'MyFile'
OPEN 'DICT','Myfile' TO @DICT ELSE STOP 201,'DICT MyFile'
SELECT item TO 0
LOOP WHILE READNEXT @ID FROM 0
READ @RECORD FROM item,@ID
total += CALCULATE(amt_due)
convtotal = OCONV(total,@CONV)
fmttotal = FMT(convtotal,@FORMAT)
© 1997-2019 InterSystems Corporation, Cambridge, MA