Kill
Kill
is an instruction that destroys variables permanently.
Syntax
Kill VAR_LIST
VAR_LIST
is a list of existing variable names separated by commas. The variables can be global or local variables.
Examples
# Let's suppress several variables
Kill MY_STRING, [V]GLOBAL_VAR, [L]AMOUNT
# Let's create an array of pointers
Local Instance POINTERS(1..10) Using C_MYCLASS
POINTERS(1)=NewInstance Using C_MYCLASS AllocGroup Null
For 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 group
FreeGroup POINTERS(1)
# Second the variable that referenced the instance
Kill 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 code | Description |
---|---|
6 | Variable does not exist. |
7 | Class does not exist. |
34 | The class mentioned for the variables is not [L] or [V]. |
See also
Raz, type, dim, FreeInstance, Freegroup.