|
The QMRead() function reads a record without locking. It is analogous to the QMBasic READ statement.
The function arguments are:
| FileNo | is the file number returned by a previous QMOpen() call. |
| Id | is the id of the record to be read. |
| Err | is an integer variable to receive status information. This argument is not present in all variants of the QMClient API. |
The QMRead() function requests the server to return the record with key Id from the file opened as FileNo.
If successful, the function returns the record as a dynamic array string and the Err variable is set to SV_OK.
If the record cannot be found, the function returns a null string and the Err variable is set to SV_ELSE. The QMStatus() function can be used to retrieve the error number.
Conditions that would normally cause a QMBasic program to abort or to take the ON ERROR clause of a READ statement return a null string and the Err variable is set to SV_ON_ERROR. The QMStatus() function can be used to retrieve the error number.
The example program fragment below opens the CLIENTS file, reads the record identified by ClientNo, and then closes the file. A real program should test the Err status from the read to determine if the action was successful.
char * QMRead(int FileNo, char * Id, int * Err)
fClients = QMOpen("CLIENTS");
Rec = QMRead(fClients, ClientNo, &Err);
QMClose(fClients);
The returned pointer references a dynamically allocated memory area that must be released using QMFree() when no longer needed. Note that attempting to read a non-existent record returns a pointer to a null string, not a NULL pointer.
|
QMRead(ByVal FileNo as Integer, ByVal Id as String, ByRef Err as Integer) as String
fClients = QMOpen("CLIENTS")
Rec = QMRead(fClients, ClientNo, Err)
QMClose(fClients)
|
Read(FileNo, Id, Err)
fClients = session->Open("CLIENTS")
Rec = session->Read(fClients, ClientNo, Err)
session->Close(fClients)
|
String Read(int FileNo, String Id)
fClients = qm.Open("CLIENTS");
Rec = qm.Read(fClients, ClientNo);
qm.Close(fClients);
If successful, the ServerError property will be SV$OK. Other values indicate an error.
|
Read(FileNo, Id)
fClients = qm.Open("CLIENTS")
Rec, Err = qm.Read(fClients, ClientNo)
qm.Close(fClients)
The function returns two values as a list; the record data and the error status. If successful, the error status is SV_OK.
|
|