ParseExpression

new to Analytica 5.2

ParseExpression( text, badVal )

Parses «text» into a parsed Analytica expression if possible. Non-text values (numbers, dates, null, etc) are passed through directly. If «text» is text and does not parse, «badVal» is returned. ParseExpression(t,t) passes through non-parsing text. No error is generated and evaluation does not stop when «text» does not parse.

Local variables in the lexical context of the call to ParseExpression are not in scope for the parse.

The result is an Analytica parse tree. This is a special data structure that acts as an atom for array abstraction.


Uses

Suppose you import a set of distribution specifications from an external source, such as a spreadsheet. These come in as text, such as "Uniform(0,1)". If you simply assign an array of these to a variable, the resulting edit table will have the text "Uniform(0,1)" instead of an expression -- i.e., there will be an extra set of quotes in the cell. To automate this process, you can parse the incoming cells before assigning, e.g.,

Assessments := ParseExpression( incomingAssessments, incomingAssessments)

The edit table cells will then contain the actual expression rather than quoted text.

See also

Comments


You are not allowed to post comments.