Parse

parse parses a formula contained in a character string and returns an error value if the formula is not syntactically correct.

Syntax

 parse(STRING_EXPR)

Examples

# First simple exampleLocal Integer FIELD1IF_OK=parse("1+1") : # FIELD1 contains now 0 (ok)IF_OK=parse("1+") : # FIELD1 contains now 5 (illegal character)# Second example: check first if the formula is syntactically valid, then manage the error# Returns the result of the evaluation in a string# If an error occurs, ERROR_CODE is not null and the result is an empty stringSubprog EVALUE(FORMULA,RESULT,ERROR_CODE)Value Char FORMULA()Variable Char RESULTVariable Integer ERROR_CODE# Is the formula correct?ERROR_CODE=parse(FORMULA)If ERROR_CODE<>0 : RESULT="" : End : Endif# Handle the errorsOnerrgo ERR_EVALUERESULT=num$(evalue(FORMULA))ERROR_CODE=0End# Error handling$ERR_EVALUERESULT=""ERROR_CODE=errnEnd

Description

parse parses the content of a character string as a formula and returns 0 if the syntax is OK. Otherwise, it returns an error code (usually 5: incorrect character).

If the argument of parse is a string array, the different lines in the array are concatenated and the result is parsed.

Comment

A second argument can be given for parse, but this syntax is deprecated and must not be used.

Associated errors

Error codeDescription.
10The argument is not a string.

See also

evalue.