Forms 8 Documentation - Scripting

Quick Start | Field Types | Scripting | Server Data Options | Advanced Functionality

Variables

Variables are used in scripting statements to represent values in calculations, and to refer to the values of fields.

Pendragon Forms scripts support the following variables:

answer

Represents the value of the current field.

Example 1: answer = 10 puts the number 10 in the current field.

Example 2: answer = $7 puts the value in field 7 into the current field.

Example 3: answer = result puts the value that is currently in the result variable into the current field.

result

Used as a temporary variable for storing intermediate calculations.

Several scripting statements also place values into the result variable.

Example 1: result = 6 + 19 stores the number 25 in the result variable.

Example 2: result = $5 + $6 adds up the values in fields 5 and 6, and places the sum of the two fields in the result variable.

Example 3: result = result + $15 adds the existing value in result to the value in field 15, and stores the sum of the two values back in the result variable.

$number

$ is a field reference, used to refer to the value in the specified field.

$[label]

Example 1: $5 means the value in field 5.

Example 2: $[OrderTotal] means the value in a field with the field label of OrderTotal.

temp

temp is a "free" variable that can be used to store data. Whereas scripting statements place values into the result variable, the value in the temp variable can be set in a script and will be preserved until you change this value in a script yourself, or until Pendragon Forms is no longer the active application on the mobile device.

null

null is a constant which is equivalent to an empty string.

Example 1: $10 = null sets the value of field 10 to null.

Example 2: calculate:
         if $4 <> null then
                  answer = $3 / $4
         endif

In this example, if field 4 is not null, then a calculation is performed.

buffer

buffer is another "free" variable that can be used to store data, similar to the temp variable. The buffer variable can be set in a script and will be preserved until you change this value in a script yourself, or until Pendragon Forms is no longer the active application on the mobile device.

lookupname

lookupname is a variable that can be used to determine the name of the Lookup List that will be displayed when a user taps in a Lookup List field. Lookupname is set with a setlookupname statement - see page 301.

lookuplocale

lookuplocale is another variable that can be used to determine the name of the Lookup List that will be displayed when a user taps in a Lookup List field. Lookuplocale is set with a setlookuplocale statement - see page 301.