|
The QMTrans() function performs the equivalent of a QMBasic TRANS() function on the server.
The function arguments are:
| FileName | is the name of the file from which data is to be read. |
| Id | is the id of the record to be read. This may be a multivalued list of record ids. |
| FieldName | is the dictionary name of the field to be returned. The dictionary record may be any valid data defining item (types A, C, D, E, I, S). Alternatively, FieldName may be specified as a numeric field position or -1 to return the entire record. |
| Action | sets the action to be taken if the data cannot be found: |
In addition,
| B | Causes the file to be opened in binary mode with mark mapping disabled. |
The QMTrans() function causes the server process to open the data file and its dictionary, execute a QMBasic TRANS() function and return the result.
The QMTrans() function returns the specified data with any mark characters lowered by one level (e.g. value marks become subvalue marks).
If record.id is multivalued, the QMTrans() function extracts each requested record and returns a multivalued result with the data from each record separated by a value mark.
The QMRTrans() function is identical to QMTrans() except that it does not lower the mark characters. This makes it impossible to distinguish between the results of retrieving a multivalued field from a single record and retrieving a single valued field from multiple records.
The example program fragments below are based on the QM demonstration database and use the QMTrans() function to fetch the current price for the parts in an order from the STOCK file.
char * QMTrans(char * FileName, char * Id, char * FieldName, char * Action)
Prices = QMTrans("STOCK", Items, "PRICE", "X");
The returned pointer references a dynamically allocated memory area that must be released using QMFree() when no longer needed. Note that attempting to read non-existent data returns a pointer to a null string, not a NULL pointer.
|
QMTrans(ByVal FileName as String, ByVal Id as String, ByVal FieldName as String, ByVal Action as String) as String
Prices = QMTrans("STOCK", Items, "PRICE", "X")
|
Trans(FileName, Id, FieldName, Action)
Prices = session->Trans("STOCK", Items, "PRICE", "X")
|
String Trans(String FileName, String Id, String FieldName, String Action)
Prices = qm.Trans("STOCK", Items, "PRICE", "X");
|
Trans(FileName, Id, FieldName, Action)
Prices = qm.Trans("STOCK", Items, "PRICE", "X")
|
See also:
QMEvaluate()
|