The name of the variable. This must be unique across variables and procedures.
opt_type
string | null
(Optional) The type of the variable like 'int' or 'string'. Does not need to be unique. Field_variable can filter variables based on their type. This will default to '' which is a specific type.
opt_id
string | null
(Optional) The unique ID of the variable. This will default to a UUID.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003ecreateVariable()\u003c/code\u003e method creates a new variable within the Blockly Workspace with a specified name, optional type, and ID.\u003c/p\u003e\n"],["\u003cp\u003eVariable names must be unique, while types can be shared and are used for filtering; IDs are auto-generated if not provided.\u003c/p\u003e\n"],["\u003cp\u003eThe method returns a \u003ccode\u003eVariableModel\u003c/code\u003e object representing the newly created variable, allowing further manipulation.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [Workspace](./blockly.workspace_class.md) \\\u003e [createVariable](./blockly.workspace_class.createvariable_1_method.md)\n\nWorkspace.createVariable() method\n---------------------------------\n\n\u003e | **Warning:** This API is now obsolete.\n\u003e\n\u003e v12: use Blockly.Workspace.getVariableMap().createVariable.\n\nCreate a variable with a given name, optional type, and optional ID.\n\n**Signature:** \n\n createVariable(name: string, opt_type?: string | null, opt_id?: string | null): IVariableModel\u003cIVariableState\u003e;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|-----------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| name | string | The name of the variable. This must be unique across variables and procedures. |\n| opt_type | string \\| null | *(Optional)* The type of the variable like 'int' or 'string'. Does not need to be unique. Field_variable can filter variables based on their type. This will default to '' which is a specific type. |\n| opt_id | string \\| null | *(Optional)* The unique ID of the variable. This will default to a UUID. |\n\n**Returns:**\n\n[IVariableModel](./blockly.ivariablemodel_interface.md)\\\u003c[IVariableState](./blockly.ivariablestate_interface.md)\\\u003e\n\nThe newly created variable."]]