QMExtract()

Top  Previous  Next

 

The QMExtract() function extracts a field, value or subvalue from a dynamic array. It is analogous to the QMBasic field extraction operator or the EXTRACT() function.

 

 

Format

 

VBQMExtract(ByVal Src as String, ByVal Fno as Integer, ByVal Vno as Integer, ByVal Svno as Integer) as String

 

Cchar * QMExtract(char * Src, int Fno, int Vno, int Svno)

 

where

 

Srcis the dynamic array to be processed

 

Fnois the number of the field to be extracted. If less than 1, 1 is assumed

 

Vnois the number of the value to be extracted. If less than 1, the entire field is extracted.

 

Svnois the number of the subvalue to be extracted. If less than 1, the entire value is extracted.

 

 

The QMExtract() function returns the given field, value or subvalue from the source string. If the required item is not found, a null string is returned.

 

 

Examples

 

VB

Rec = QMRead(fClients, ClientNo, ErrNo)

CliAddr = QMExtract(Rec, 4, 0, 0)

C

Rec = QMRead(fClients, ClientNo, ErrNo);

CliAddr = QMExtract(Rec, 4, 0, 0);

 

The above program fragment reads the record identified by ClientNo from the file open as fClients and then extracts field 4 from it. 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 CliAddr pointing to a dynamically allocated memory area that must be released using QMFree() when no longer needed.