var (Read form variable)

Prev Next

The $var function makes it possible to read the content of a previously Set variable in forms (e.g. in another element's behavior).

Hint: Form flags are also variables.

Tooltip

Syntax: $var(varName)

Parameter

Description

varName

The name of the variable.

Returns the value of the variable or null if it is not set or empty.

Syntax

$var(varName)

Parameter

Name

Description

varName

The name of the variable.

Return value

The value of the variable or null if it is not set or empty.

Example

In the following example, in a behavior with every 'Change' (1) the content of the text field is written to a variable named 'content' (2).

images/download/attachments/62864048/image2019-12-2_12-0-1-version-1-modificationdate-1610720662817-api-v2.png

When you click on the Read variable... button (3), a Calculate behavior is executed (4), which reads the variable 'content' and passes it to a Show alert action (5), which displays this value.

images/download/attachments/62864048/image2019-12-2_12-3-57-version-1-modificationdate-1610720662799-api-v2.png

Result:

images/download/attachments/62864048/image2019-12-2_12-6-9-version-1-modificationdate-1610720662787-api-v2.png