A Variable is a placeholder to store a value. A variable is called a Parameter when it is an input to a function (Refer See "Parameters").
A user can also declare local variables making them available for use within the script. A variable is declared before the begin...end block of the script skeleton (Refer See "Scripts").
procedure ScriptEvent (var Value : variant);
var
MyVariable : Integer
MyVariable2 : String
begin
end;
A variable is declared as a certain data type indicating the type of data the variable can store. The syntax for declaring variables is
var <VariableName> : <DataType>;
var is a keyword indicating you are declaring a variable. If declaring multiple variables you only need this once at the start of the list of variables. See example below
<VariableName> is the desired name of the variable and can be what ever the user desires (However the first character should always be a alpha character from A-Z)
<DataType> is one of the supported See "Data Types".
A variable has a scope which indicates the availability of the variable from within the script. Scope is described as either Local or Global. A Local variable is only available within the script it is declared. A Global variable is available within any script within the map.
Variables are also either Persistent or Non-Persistent. All variables declared by the user are non-persistent. Non-persistent variables do not retain their value between executions of the script, they always start as null each time the script executes. For example, in a script assigned to the OnMap event of a field, a variable will start as null each time the script executes (it will execute once for each record being processed). Persistent variables retain their value between each execution of the script.
Note: Any variables declared by a user are Local variables and only available within the script they are declared within. User declared variables are non-persistent - they will start as null each time the script executes.
A user cannot declare Global variables.
Some examples of declaring a variable are;
var MyVariable : String declares a variable called MyVariable of See "String (String, Widestring)" data type
var Temp : TDateTime declares a variable called Temp of See "Datetime (TDateTime)" data type
var Total : Double; Count : Integer; Temp : String; declares three variables. The first is called Total of See "Float (Double, Extended, Currency)" data type, the second is called Count of See "Integer (Integer, Cardinal, Int64)" data type, and the third is called Temp of See "String (String, Widestring)" data type.
Variable names are not case sensitive in a script. If you declare as MyVariable you can reference it is myvariable
As well as local variables declared by the user as above, there are also special variables that are available within the script engine:
Special Variable | Predeclared Names | Data Type | Scope / Persistence |
---|---|---|---|
Global Variables | Global1 to Global10 | Variant | Across Events in one execution of a Map |
Global Datasets | Data1 to Data10 (to Data35 in recent versions) |
TFloClientDataSet | Across Events in one execution of a Map |
Super Globals | Globals['<anyname>'] | Variant | The lifetime of that Flow session in memory (or until RemoveGlobal or ClearAllGlobals) |
Local Globals | Locals['<anyname>'] | Variant | Across Action Steps in one execution of an Action (or until RemoveLocal or ClearAllLocals) |