problem.parsecformula
problem.parsecformula |
Purpose
Parse a formula written as a character string into internal parsed (reverse Polish) format
Synopsis
ntoken = problem.parsecformula (formula, type, value)
Arguments
ntoken
|
Number of tokens in the parsed formula (not counting the terminating
xslp_op_eof token).
|
formula
|
Character string containing the formula, written in the same free-format style as used in formulae in Extended MPS format, with spaces separating tokens.
|
Type
|
Array of token types providing the parsed formula.
|
Value
|
Array of values corresponding to the types in
Type.
|
Example
Assuming that
x and
y are already defined as columns, the following example converts the formula "sin(x+y)" into internal parsed format, and then writes it out as a sequence of tokens.
type = [] value = [] ntoken = p.parsecformula ("sin ( x + y )", Type, Value) i = 0 while type[i] != xslp_op_eof: str = p.itemname (type[i], value[i]) printf (str) i += 1
Further information
Tokens are identified by name, so any columns or user functions which appear in the formula must already have been defined. Unidentified tokens will appear as type xslp_UNKNOWN.
Related topics