Skip to main content

blockly > Variables > getVariable

Variables.getVariable() function

Look up a variable on the given workspace. Always looks in the main workspace before looking in the flyout workspace. Always prefers lookup by ID to lookup by name + type.

Signature:

export declare function getVariable(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): IVariableModel<IVariableState> | null;

Parameters

Parameter

Type

Description

workspace

Workspace

The workspace to search for the variable. It may be a flyout workspace or main workspace.

id

string | null

The ID to use to look up the variable, or null.

opt_name

string

(Optional) The string to use to look up the variable. Only used if lookup by ID fails.

opt_type

string

(Optional) The type to use to look up the variable. Only used if lookup by ID fails.

Returns:

IVariableModel<IVariableState> | null

The variable corresponding to the given ID or name + type combination, or null if not found.