Limitations of the Formula Language
Although the Formula language has similarities to many other programming languages, there are some important differences. The Formula language is great because it does not usually require as much coding as a scripting language that performs the same function. Although the scripting languages generally require more effort, they also have greater capabilities. Despite its ease of use, the Formula language has some rather severe limitations, but by no means should this discourage you from using the Formula language. Not only do many situations require the use of the Formula language, but there are many reasons to choose the Formula language over a scripting language.
Some of the most limiting factors for the Formula language are the following:
- A formula cannot repeatedly loop through a collection of documents; there is no looping construct in the Formula language.
- There is no way to create subroutines.
- The scope is limited to the formula itself; variables have no persistence beyond the currently executing formula.
- You cannot directly pass a parameter from one formula to another or even to an agent; similarly, you cannot call a formula with a parameter. (You can, however, store a value to an environment variable or a field and retrieve it later to partially work around this limitation.)
- There is no method to transfer control outside the formula itself, perhaps to another formula, although you can stop a formula with @Return() . You can get around this to a certain extent by calling an agent.
A number of events must be scripted with another language and cannot have formulas written to them. These events can be found in agents , forms, fields, views, and database scripts. Examples are the Initialize event for agents, the QuerySave event for forms, and the Exiting event for fields.