Skip to main content

Function: getVariable()

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

Defined in: packages/blockly/core/variables.ts:691

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.

Parameters

ParameterTypeDescription
workspaceWorkspaceThe workspace to search for the variable. It may be a flyout workspace or main workspace.
idstring | nullThe ID to use to look up the variable, or null.
opt_name?stringThe string to use to look up the variable. Only used if lookup by ID fails.
opt_type?stringThe 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.