Kill

Kill is an instruction that destroys variables permanently.

Syntax

 Kill VAR_LIST

Examples

 # Let's suppress several variablesKill MY_STRING, [V]GLOBAL_VAR, [L]AMOUNT# Let's create an array of pointersLocal Instance POINTERS(1..10) Using C_MYCLASSPOINTERS(1)=NewInstance Using C_MYCLASS AllocGroup NullFor I=2 to dim(POINTERS)POINTERS(I)=NewInstance Using C_MYCLASS AllocGroup POINTERS(I-1)Next I...# Now let's free everything:# First the allocation groupFreeGroup POINTERS(1)# Second the variable that referenced the instanceKill POINTERS

Description

Kill allows you to delete a variable. Only variables in [L] or [V] class can be killed.

Comments

An old syntax allows you to use Kill with [L] as a unique argument to destroy all the variables in the local class. This is not recommended for several reasons:
* Such a class is automatically destroyed when an End instruction is encountered. Therefore, the need does not exist.
* The parameter descriptions of a call are in the [L] class. Although it does not destroy the variables sent as references, you do not have access to the corresponding reference in the call after the Kill is done.

Kill only frees the memory used by variables declared as Local or Global variables or arrays. The memory spent by a NewInstance instruction must be freed by Freegroup or Freeinstance.

Associated errors

Error codeDescription
6Variable does not exist.
7Class does not exist.
34The class mentioned for the variables is not [L] or [V].

See also

Raz, type, dim, FreeInstance, Freegroup.