Expression Processing |
Top Previous Next |
When an expression is used, there are two stages to its processing: Parsing and Execution. It isn't strictly necessary to know about this or understand it, but it can help in some cases to know the difference.
Parsing goes through the expression (which is actually just text to begin with) and converts the elements to an internal structure that's easy to execute. You might think of this as "compiling" in a language like C++ or Pascal. The syntax is evaluated for errors, function names are looked up, and it's converted to an operation tree.
Execution goes through the operation tree, calling any functions to evaluate the elements as needed, and evaluating the operators until it gets a single result for the expression.
In many cases, these simply happen one after another and it doesn't really matter whether it takes longer to parse or execute. However, in Queries where the program knows that the same expression is going to be needed many times (e.g. once for each record used in the report), it only parses the expression once. Then it does the execution of the expression many times, each time with a different record as the context record.
Sometimes you can use this to your advantage. For instance if you have a complex expression that involves some iif() conditions, you may not want it to execute both possible expression results in the function. In this case, it may work best to use the quoted-expression iifq() version. This will delay execution (and parsing) of the result parameters and only evaluate the one result that's needed.
Expression Errors
Whenever an expression is parsed or executed, error checking is performed. Depending on the function you're using, you may be able to see any errors encountered.
When using the Expression Creator dialog, you can "Calculate" the expression to check for basic syntax errors or other problems, to a limited extent.
When using the Save & Test function for Queries, Forms, Scripts, etc., any errors encountered may be shown as pop-up tips in a query or dialogs, or inside the form where the expression was to appear.
Additional Topics:
Advanced Customizations Overview & other topics