Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.00

Description

Description:

Return the value of variable in the variable space of given element.

The command is case sensitive (for example, getVariable "Status" is not the same as getVariable "status").

Variables can be assigned to the following entities:

Syntax

Syntax:element getVariable name
Parameters:
  • element: Anything - Entity the variable is assigned to (see description for compatible types).
  • name: String - Name of variable used in setVariable.
Return Value:Anything

Alternative Syntax

Syntax:element getVariable [name,default] (V2.0+)
Parameters:
  • element: Anything - Entity variable was assigned to (see description for compatible types)
  • name: String - Name of variable used in setVariable
  • default: Anything - Default value to return, if variable is not defined. Since V17.1+, the default value is used also for null element.
Return Value:Anything

Examples

Examples:
_status = plane1 getVariable "status"
_status = plane1 getVariable ["status","idle"]

Additional Information

See also: setVariable, VBS Object Variables
Multiplayer:
Problems: Alternative syntax does not work on UI controls (for example, _map getVariable ["status", "idle"] returns null). This issue is present as of 18.3 and has been reported.

Notes





Posted on Oct 11, 2009
Kronzky
To check whether a variable was set at all, you can use the following code


if (isNil {obj getVariable "var"}) then {
   // do something
};