|
The QMSelectIndex() function generates a select list from an alternate key index.
The function arguments are:
| FileNo | is the file number returned by a previous QMOpen() call. |
| IndexName | is the name of the alternate key index to be used. |
| IndexValue | is the value to be located in the alternate key index. |
| ListNo | is the select list number (0 to 10). |
The QMSelectIndex function constructs a list of record ids from an entry in an alternate key index. This list can subsequently be processed using the QMReadNext() function. Select list 0, the default select list, is used automatically by many QM components to control their action and should, therefore, be used with caution. An unwanted or partially processed select list can be cleared using the QMClearSelect function.
The number of items in the select list can be established by using QMGetVar() to retrieve the @SELECTED variable immediately after the QMSelectIndex().
See the QMReadList() function for a discussion on different ways to process the select list.
The example program fragments below build select list 1 from an index and use it to process records from the file open as fClients.
void QMSelectIndex(int FileNo, char * IndexName, char * IndexValue, int ListNo)
QMSelectIndex(fClients, "REGION", RegionNo, 1);
while((Id = QMReadNext(1)) != NULL)
{
Rec = QMRead(fClients, Id, Err);
if (Err == 0)
{
...process record...
QMFree(Rec);
}
QMFree(Id);
}
Note the use of QMFree() to release the dynamically allocated memory from some of the functions in this example.
|
QMSelectIndex ByVal FileNo as Integer, ByVal IndexName as String, ByVal IndexValue as String, ByVal ListNo as Integer
QMSelectIndex fClients, "REGION", RegionNo, 1
Do
Id = QMReadNext(1, Err)
If Err <> 0 Then Exit Do
Rec = QMRead(fClients, Id, Err)
If Err = 0 Then
...process record...
End If
Loop
|
SelectIndex(FileNo, IndexName, IndexValue, ListNo)
session->SelectIndex(fClients, 'REGION', RegionNo, 1))
loop
Id = session->ReadNext(1)
until Id = ""
Rec = session->Read(fClients, Id, Err)
if Err = 0 then
...process record...
end
repeat
|
SelectIndex(int FileNo, String IndexName, String IndexValue, int ListNo)
qm.SelectIndex(fClients, "REGION", RegionNo, 1);
qm.Select(fClients, 1);
while((Id = qm.ReadNext(1)) != NULL)
{
Rec = qm.Read(fClients, Id);
if (qm.ServerError == SV$OK)
{
...process record...
}
}
|
SelectIndex(FileNo, IndexName, IndexValue, ListNo)
qm.SelectIndex(fClients, "REGION", RegionNo, 1)
while True:
Id = qm.ReadNext(1)
if Id = "": break
Rec, Err = qm.Read(fClients, Id)
...process record...
|
|