QMMatchfield()

Top  Previous  Next

 

The QMMatchfield() function matches a character string against a pattern template and extracts the part corresponding to a specified pattern component. It is analogous to the QMBasic MATCHFIELD() function.

 

 

Format

 

VBQMMatchfield(ByVal Src as String, ByVal Pattern as String, ByVal Component as Integer) as String

 

Cchar * QMMatchfield(char * Src, char * Pattern, int Component)

 

where

 

Srcis the string to be processed.

 

Patternis the pattern template to be used.

 

Componentis the pattern template component number for which the corresponding part of Src  is to be returned.

 

 

The QMMatchfield() function matches Src against the Pattern template as described for the QMMatch() function. If the string matches, the portion corresponding to the specified Component is returned. If the string does not match the pattern, a null string is returned.

 

 

Examples

 

VB

Prefix = QMMatchfield(PartCode, "2-4A3N", 1)

C

Prefix = QMMatchfield(PartCode, "2-4A3N", 1);

 

The above example returns the alphabetic prefix of a value stored in PartCode if it is formed from between two and four letters followed three digits.

 

Note that Prefix variable in the C example points to dynamically a allocated memory area that must be released using QMFree() when no longer needed.

 

This function is evaluated on the client system and does not require a server connection to be open.