Remove a variable
Remove a variable by using the DestroyVariableByName method or the DestroyVariableById method.
Remove a transient variable by using the DestroySessionVariable method.
Script-defined variables cannot be removed using the DestroyVariableById method or the DestroyVariableByName method. See the example below for more information on how to remove a script-defined variable.
Examples
Example 1:
The variable has 2 as a handle.
1. Remove the variable. The variable has for identifier VB01.
The client sends:
The engine returns:
The variable is successfully removed and the handle of the variable is closed.
Example 2:
The first step is to edit the script and add two variables.
The second step is to reload the app.
The third step is to remove the variables from the script. After reloading the app, the variables do no longer exist in the script. The variables become user variables (like if the variables had been created with the CreateVariableEx method) and can thus be removed using the DestroyVariableById method or the DestroyVariableByName method.
1. Create two variables vSales and vSales2 using the SetScript method.
The client sends:
The engine returns:
The variables are created. The type of a script-defined variable is variable.
2. Reload the script.
The client sends:
The engine returns:
The script is reloaded.
3. Edit the script and remove the variables using the SetScript method.
The client sends:
The engine returns:
The script is updated.
4. Reload the script.
The client sends:
The engine returns:
The script is reloaded. The script-defined variable do no longer exist.
5. Create a transient object to list the variables of type variable in the app.
The client sends:
The engine returns:
The list of variables is created and has 2 as a handle.
6. Get the layout of the list.
The client sends:
The engine returns:
The variables vSales and vSales2 are listed, even if they are removed from the script.
7. Remove the variablevSales using the DestroyVariableByName method.
The client sends:
The engine returns:
The variable is successfully removed.
8. Remove the variablevSales2 using the DestroyVariableByName method.
The client sends:
The engine returns:
The variable is successfully removed.
9. Check that the list of variables is empty using the GetLayout method.
The client sends:
The engine returns:
The variables are no longer listed.