FORMULA LANGUAGE
The syntax for creating a temporary variable is:
Using a variable name on the lefthand side of an equation results in a temporary variable unless preceded by the reserved word FIELD.
The following example makes extensive use of temporary variables to place the name of the current month in a field named MonthName. The steps are:
1. Place the current date in the temporary variable date.
2. Extract from date and convert to text month, the number of the month.
3. Create a text list "nMonths" with the values 1 through 12.
4. Create a text list "months" with the values January through December.
5. Replace the number value of the current month with its name.
date := @Created; month := @Text(@Month(date)); nMonths := "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9" : "10" : "11" : "12"; months := "January" : "February" : "March" : "April" : "May" : "June" : "July" : "August" : "September" : "October" : "November" : "December"; FIELD MonthName := @Replace(month; nMonths; months)
Variables can be assigned new values as a formula progresses.
Note Reassignment of a variable is new with Release 6. In previous releases, an attempt to reassign a variable resulted in an error.
The following example reassigns the temporary variable n at each iteration of an @While loop.
n := 1; @While(n <= @Elements(Categories); @Prompt([OK]; "Category " + @Text(n); Categories[n]); n := n + 1
)
See Also