QMClearSelect

Top  Previous  Next

 

The QMClearSelect function clears a select list. It is analogous to the QMBasic CLEARSELECT statement.

 

 

Format

 

VBQMClearSelect ByVal ListNo as Integer

 

Cvoid QMClearSelect(int ListNo)

 

ObjSession->ClearSelect(ListNo)

 

where

 

ListNois a valid select list number (0 to 10)

 

 

 

The QMClearSelect function clears the specified select list. No error occurs if the list was not active.

 

Applications that use select list 0 (the default select list) and could leave unprocessed items in the list should always clear it to avoid unwanted effects on later server processing.

 

 

Examples

 

VB

QMSelect fClients, 1

Do

  Id = QMReadNext(1, ErrNo)

  If ErrNo <> 0 Then Exit Do

  Rec = QMRead(fClients, Id, ErrNo)

  If QMExtract(Rec, 1, 0, 0) = "" Then Exit Do

Loop

QMClearSelect 1

C

QMSelect(fClients, 1);

do {

   Id = QMReadNext(1);

   if (Id == NULL) break;

   Rec = QMRead(fClients, Id, ErrNo);

   QMFree(Id);

   Fld = QMExtract(Rec, 1, 0, 0);

   if (Fld == NULL) break;

   QMFree(Rec);

   QMFree(Fld);

  } while(1);

QMClearSelect(1);

QMBasic

session->Select(fClients, 1)

loop

  Id = session->ReadNext(1)

until Id = ""

  Rec = session->Read(fClients, Id, ErrNo)

until Rec<1> = ""

repeat

session->ClearSelect(1)

 

The above program fragment 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 will leave a partially processed select list, QMClearSelect is used to clear the list.

 

Note that the C example leaves variables Rec and Fld pointing to dynamically allocated memory areas on exit from the loop. These must be released using QMFree() when they are no longer needed.