XSLPqparse
XSLPqparse |
Purpose
Perform a quick parse on a free-format character string, identifying where each token starts
Synopsis
int XPRS_CC XSLPqparse(char *Record, char *Token[], int NumFields);
Arguments
Record
|
Character string to be parsed. Each token must be separated by one or more spaces from the next one.
|
Token
|
Array of character pointers to receive the start address of each token.
|
NumFields
|
Maximum number of fields to be parsed.
|
Return value
The number of fields processed.
Example
The following example does a quick parse of the formula "sin(x+y)" to identify where the tokens start, and then prints the first character of each token.
char *Token[20]; int i, n; n = XSLPqparse("sin ( x + y )",Token,20); for (i=0;i<n;i++) printf("\nToken[%d] starts with %c",i,Token[i][0]);
Further information
XSLPqparse does not change Record in any way. Although Token[i] will contain the address of the start of the ith token, the end of the token is still indicated by a space or the end of the record.
The return value of XSLPqparse is the number of fields processed. This will be less than NumFields if there are fewer fields in the record.