FANDOM


Removes a variable from memory.

Syntax:

delete {local | global | variable} {variableName | arrayIndex}

Synonyms: clear variable

Examples:

delete local tempVariable
global gArray
delete global gArray[17]

Use the delete variable command to free memory used by a large variable, or to clean up after using many variable names.

The variableName is the name of any local or global variable.

The arrayIndex is a key of an array variable. If an arrayIndex is specified instead of a variable name, the delete variable command removes that element of the array, without deleting the rest of the elements in the array.

The delete variable command not only removes the contents of the variable, but deletes it entirely from memory. If you delete a key from an array variable, that element of the array no longer exists as part of the variable.

Local variables that are used within a handler are automatically deleted when the handler in which they are used exits.

You can't delete local or global variables, using delete you just put the value empty in them.

NoteEdit

When deleting variables, the variable MUST have been previously referenced in the script prior to being deleted. For example, if you have declared a global variable elsewhere in your stack, you may not delete it without creating a reference to it first inside the handler which deletes it.

This code will not work:

delete global gGlobalVariable

This code will work:

global gGlobalVariable
delete global gGlobalVariable

See AlsoEdit

globalNames Function, delete Command, local Command, empty Constant

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.