Evaluation Time
For each formula, i-net Clear Reports decides when to evaluate and calculate the results of the formula. Depending on when the formula is evaluated and thereby also how often, the results can very greatly.
In Basic syntax the optional operator "Call" can be used to call these evaluation time functions with return value.
A formula can have the following three different possible evaluation times. In the following you can read the explanations of each each evaluation time as well as which ones i-net Clear Reports uses by default:
BeforeReadingRecords
This type of formula is evaluated once, at the beginning of report execution. During report execution, the result value is then given directly (not calculated) to all places where it is used in the report.
i-net Clear Reports chooses this evaluation time for formulas which are evaluable before report execution - that is, all formulas that do not contain database fields or certain special functions such as PageNumber or TotalPages.
Manually setting BeforeReadingRecords is unnecessary because i-net Clear Reports will either use this evaluation time anyways, or will give you an error message, because it is not allowed to manually set BeforeReadingRecords if it is not possible (for example you could not specify "BeforeReadingRecords" if your formula contains a parameter field or a database field, since in order to evaluate the formula's result, it would have to read the field's record).
Examples:
This will return a "1" for every usage of x, because i-net Clear Reports uses "BeforeReadingRecords" by default:
global numbervar x; x := x+1
WhileReadingRecords
This type of formula is evaluated once for each record, while the records are being read, but before they are "printed" into the report.
The evaluation time of this type is before the group selection formula is executed and the summary functions are calculated. The record selection formula and the formulas used as group field, sort field are also from type "While Reading Records" and will be executed in the order of their creation.
Manually setting WhileReadingRecords is allowed for any formula which does not need to have read all records before being able to be evaluated. Therefore, WhileReadingRecords is not allowed for formulas which summarize all database fields, or which use a special function like TotalPages.
Examples:
This will return a string value for each record:
WhileReadingRecords; ToText( {Orders.EmployeeID})
WhilePrintingRecords
This type of formula is evaluated once for each record while "printing" the results of the report.
i-net Clear Reports uses this evaluation time by default for all formulas which type is not "Before Reading Records".
Manually setting WhilePrintingRecords is always allowed and will cause the formula to be evaluated after all records were read and once for each record being printed into the report.
Examples:
This returns a result of a sum of all records of one field grouped by other field. This can be use only as "While Printing Records":
WhilePrintingRecords; Sum( {Orders.OrderID}, {Orders.EmployeeID} )
EvaluateAfter (x)
Using EvaluateAfter, you can force the formula to be evaluated directly after a different formula. With that function you can force the evaluation order of your formulas. You'll usually use this function if multiple formulas are used in the same section and the formulas use the same global variables, so that you can control when the variable is changed how.
Examples:
Formula "ValueOfOrderedGood": global numbervar valueOfGood; valueOfGood :={Order_Details.Quantity} * {Order_Details.UnitPrice}
Formula "ValueOfOrderedGoodWithTax": evaluateAfter( {@ValueOfOrderedGood} ); global numbervar valueOfGood; valueOfGood := valueOfGood + 20%valueOfGood;