Formulas are not evaluated "on demand" or called (that is, one formula cannot call another formula to do some processing, even through the use of global variables).
For example:
Rem Formula PrintSquare Global x As Number x = 5 formula = "The square of " & CStr(x,0) & " is " & ToText ({@square}, 0) & "." Rem Formula Square Global x As Number formula = x * x
Using formula PrintSquare in a report, you get:
The square of 5 is 0.
In this example, formula PrintSquare uses formula Square, so Crystal Reports order their evaluations. First Square is evaluated and then PrintSquare is evaluated. When Square is evaluated, the value of the global variable x is 0, since that is the value of an uninitialized Number variable.
In contrast, custom functions are evaluated on demand, or called. Using a custom function in the previous example:
Rem Formula PrintSquare formula = "The square of " & CStr (5,0) & " is " & CStr(cf9Square (5),0) + "." Rem Custom Function cf9Square Function cf9Square (x As Number) cf9Square = x * x End Function
Now if you use formula PrintSquare in your report, you'll get:
The square of 5 is 25.
Creating Custom Functions | Basic Syntax for Custom Functions | Crystal Syntax for Custom Functions