The QMClearSelect() function clears a select list. It is analogous to the QMBasic CLEARSELECT statement.
The function takes a single argument, ListNo, which is the select list number to be cleared. This must be in the range 0 to 10. No error occurs if the list was not active.
Applications that could leave unprocessed items in the list should always clear when it is no longer required. This is particularly important with the default select list (list 0) as items left in this list may affect commands executed on the server later in the session.
The program fragment in the examples below builds select list 1 and uses it to process records from the file open as fClients. It exits from the loop when it finds the first record where field 1 is empty. Because this could leave a partially processed select list, QMClearSelect() is used to clear the list.
void QMClearSelect(int ListNo)
Id = QMReadNext(1);
if (Id == NULL) break;
Rec = QMRead(fClients, Id, Err);
Fld = QMExtract(Rec, 1, 0, 0);
if (Fld == '\0') break;
Note that this example leaves variables Fld pointing to a dynamically allocated memory area on exit from the loop. This must be released using QMFree() when no longer needed.
QMClearSelect ByVal ListNo as Integer
QMSelect fClients, 1
Id = QMReadNext(1)
If ID is Nothing Then Exit Do
Rec = QMRead(fClients, Id, Err)
If QMExtract(Rec, 1, 0, 0) = "" Then Exit Do
Id = session->ReadNext(1)
until Id = ""
Rec = session->Read(fClients, Id, Err)
until Rec<1> = ""
Id = qm.ReadNext(1);
if (qm.ServerError != SV$OK) break;
Rec = qm.Read(fClients, Id);
Fld = qm.Extract(Rec, 1, 0, 0);
} while(Fld.length() != 0);
Id = qm.ReadNext(1)
if Id = "": break
Rec, Err = QMRead(fClients, Id)
If Err != SV_OK: break
Fld = QMExtract(Rec, 1, 0, 0)
if Fld == "": break