QMOpen()

Top  Previous  Next

 

The QMOpen() function opens a file. It is analogous to the QMBasic OPEN statement.

 

 

Format

 

VBQMOpen(ByVal FileName as String) as Integer

 

Cint QMOpen(char * FileName)

 

ObjFileNo = Session->Open(FileName)

 

where

 

FileNameis the name of the file to be opened. This must correspond to an F or Q-type entry in the VOC of the QM account in which the server is running.

 

 

The QMOpen() function opens a QM database file. The returned integer value is the file number which must be used in all subsequent operations against this file. If the file cannot be opened, the function returns zero. The QMStatus() function can be used to retrieve the error cause.

 

To open a dictionary, the FileName argument should commence with "DICT" and a single space separating this prefix from the file name, for example:

 

DictNo = QMOpen("DICT READERS")

 

 

There is no practical limit to the number of files that can be open at one time.

 

 

Examples

 

VB

fClients = QMOpen("CLIENTS")

Rec = QMRead(fClients, ClientNo, ErrNo)

QMClose(fClients)

C

fClients = QMOpen("CLIENTS");

Rec = QMRead(fClients, ClientNo, ErrNo);

QMClose(fClients);

QMBasic

fClients = session->Open("CLIENTS")

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

session->Close(fClients)

 

The above program fragment opens the CLIENTS file, reads the record identified by ClientNo, and then closes the file. A real program should test the ErrNo status from the read to determine if the action was successful.

 

Note that the C example leaves variables Rec pointing to a dynamically allocated memory area that must be released using QMFree() when no longer needed.