QMReadNext()

Top  Previous  Next

 

The QMReadNext() function retrieves the next entry from a select list. It is analogous to the QMBasic READNEXT statement.

 

 

Format

 

VBQMReadNext(ByVal ListNo as Integer, ByRef Errno as Integer) as String

 

Cchar * QMReadNext(int ListNo)

 

ObjStr = Session->ReadNext(ListNo, ErrNo)

 

where

 

ListNois the number of the select list to be processed in the range 0 to 10.

 

Errnoreceives an error value indicating the outcome of the request. The C API does not have this argument and returns NULL if an error occurs.

 

 

The QMReadNext() function retrieves the next entry from the select list identified by the ListNo argument.

 

If successful, the function returns the list entry and, in the Visual Basic and QMBasic APIs, Errno is set to SV_OK.

 

If the list is empty, the Visual Basic and QMBasic API functions return a null string and Errno is set to SV_ELSE. In the C API implementation, the function returns NULL.

 

See Select lists in QMClient sessions for a description of the alternative ways to handle select list with QMClient.

 

See also the QMReadList() function for a discussion of the relationship between QMReadNext() and QMReadList().

 

 

Note that in the C API library, the returned string is dynamically allocated. A loop containing a call to this function must free the memory from each call separately.

 

 

Examples

 

VB

QMSelect fClients, 1

Do

  Id = QMReadNext(1, ErrNo)

  If ErrNo <> 0 Then Exit Do

  Rec = QMRead(fClients, Id, ErrNo)

  If ErrNo = 0 Then Go Sub ProcessRecord

Loop

C

QMSelect(fClients, 1);

while((Id = QMReadNext(1)) != NULL)

{

 if (Id == NULL) break;

 Rec = QMRead(fClients, Id, ErrNo);

 if (ErrNo == 0)

  {

   ProcessRecord();

   QMFree(Rec);

  }

 QMFree(Id);

}

QMBasic

session->Select(fClients, 1)

loop

  Id = session->ReadNext(1)

until Id = ""

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

  If ErrNo = 0 then gosub ProcessRecord

repeat

 

The above program fragment builds select list 1 and uses it to process records from the file open as fClients.

 

Note that the C example uses QMFree() to release dynamically allocated memory areas returned from QMClient API calls.