QMEvaluate(), QMEvalConv()

Top  Previous  Next

 

The QMEvaluate() function evaluates a dictionary data defining item. It is analogous to the QMBasic ITYPE() function. The QMEvalConv() function is identical except that it applies any conversion code specified in the dictionary item.

 

 

Format

 

VBQMEvaluate(ByVal FileNo as Integer, ByVal Name as String, ByVal Data as String, ByVal Id as String) as String

 

Cchar * QMEvaluate(int FileNo, char * Name, char * Data, char * Id)

 

ObjSession->Evaluate(FileNo, Name, Data, Id)

 

where

 

FileNois the file number associated with the dictionary of the file, as returned by QMOpen().

 

Nameis the name of the dictionary I-type record.

 

Datais the data from the record for which the I-type is to be evaluated. This data will  be copied into @RECORD on the server.

 

Idis record id of the record for which the I-type is to be evaluated. This data will  be copied into @ID on the server. If the I-type expression does not reference  @ID, this is ignored and is best passed as a null string.

 

 

The QMEvaluate() function evaluates the specified dictionary expression. Like the QMBasic ITYPE() function, it can evaluate all data defining dictionary items(A/C/D/I/S type). Where the dictionary item is a calculated value (C/I type or A/S type with correlative), it must have previously been compiled (see the COMPILE.DICT command).

 

The QMEvaluate() function evaluates the data item but does not apply any conversion and format codes specified in the dictionary. The QMEvalConv() function applies conversion codes to the evaluated item but not format codes.

 

Because the QMEvaluate() function must read the dictionary record every time that it is evaluated, applications that execute this function in a loop for many records using the same dictionary item are likely to perform best if record caching is enabled (See the RECCACHE configuration parameter).

 

 

Examples

 

VB

DataFno = QMOpen("SALES")

DictFno = QMOpen("DICT SALES")

DataRec = QMRead(DataFno, OrderNo, ErrNo)

OrderValue = QMEvaluate(DictFno, "SALE.VALUE", DataRec, "")

C

DataFno = QMOpen("SALES");

DictFno = QMOpen("DICT SALES");

DataRec = QMRead(DataFno, OrderNo, &ErrNo);

OrderValue = QMEvaluate(DictFno, "SALE.VALUE", DataRec, "");

QMBasic

DataFno = session->Open("SALES")

DictFno = Session->Open("DICT SALES")

DataRec = Session->Read(DataFno, OrderNo, ErrNo)

OrderValue = Session->Evaluate(DictFno, "SALE.VALUE", DataRec, "")

 

The above program fragment opens the data and dictionary parts of the SALES file, reads a data record, and evaluates the SALE.VALUE dictionary item without applying the associated conversion code, if present. A real program should include error handling.

 

Using QMEvalConv() in place of QMEvaluate() in the above examples would return OrderValue as the result of evaluating the SALE.VALUE dictionary item and then applying any conversion code.