---
url: /flow/guide/scripting-reference/variables.md
---

# Variables

A Variable is a placeholder to store a value. A variable is called a Parameter when it is an input to a function (Refer [Parameters](/flow/guide/scripting-reference/functions/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 [Scripts](/flow/guide/scripting-reference/scripts)).

```pascal
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

```pascal
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 [Data Types](/flow/guide/scripting-reference/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.

::: tip
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.
:::

::: danger
A user cannot declare Global variables.
:::

Some examples of declaring a variable are;

`var MyVariable : String` declares a variable called MyVariable of [String (String, Widestring)](/flow/guide/scripting-reference/data-types/string) data type

`var Temp : TDateTime` declares a variable called Temp of [Datetime (TDateTime)](/flow/guide/scripting-reference/data-types/datetime) data type

`var Total : Double; Count : Integer; Temp : String;` declares three variables. The first is called Total of [Float (Double, Extended, Currency)](/flow/guide/scripting-reference/data-types/float) data type, the second is called Count of [Integer (Integer, Cardinal, Int64)](/flow/guide/scripting-reference/data-types/integer) data type, and the third is called Temp of [String (String, Widestring)](/flow/guide/scripting-reference/data-types/string) data type.

::: tip
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](/flow/guide/scripting-reference/variables/global-variables) | Global1 to Global10 | Variant | Across Events in one execution of a Map |
| [Global Datasets](/flow/guide/scripting-reference/variables/global-datasets) | Data1 to Data10  (to Data35 in recent versions) | TFloClientDataSet | Across Events in one execution of a Map |
| [Super Globals](/flow/guide/scripting-reference/variables/super-globals) | Globals\['\<anyname>'] | Variant | The lifetime of that Flow session in memory  (or until RemoveGlobal or ClearAllGlobals) |
| [Local Globals](/flow/guide/scripting-reference/variables/local-globals) | Locals\['\<anyname>'] | Variant | Across Action Steps in one execution of an Action  (or until RemoveLocal or ClearAllLocals) |
