Tech Tip: A utility wrapper for the CLEAR VARIABLE commande
PRODUCT: 4D | VERSION: 13.5 | PLATFORM: Mac & Win
Published On: April 3, 2015
The CLEAR VARIABLE command was introduced in 4D v11. It is a very efficient way to clear 4D variables of any variable type -- local, process, inter-process, array or not.
If there is a large number of variables to be cleard it will add a line of code for every variable to be cleared.
The wrapper below add coding effiniency by adding one line of code regardless of number of variables to be cleared.
If (True) If (False) Begin SQL /* Name: UTIL_ClearVariables Path: UTIL_ClearVariables Purpose: Clear Variables wrapper $1 - C_POINTER - Pointer to a variable */ End SQL End if C_TEXT($MethodName_T) $MethodName_T:=Current method name //===================== Declare Variables ================================== //method_parameters_declarations C_POINTER(${1}) //-------------------------------------------------------------------------- //method_wide_constants_declarations //-------------------------------------------------------------------------- //local_variable_declarations C_LONGINT($Ndx;$SOA;$RIS;$Params_L) End if //====================== Initialize and Setup ================================ $Params_L:=Count parameters //======================== Method Actions ================================== For ($Ndx;1;$Params_L) CLEAR VARIABLE(${$Ndx}->) End for //======================== Clean up and Exit ================================= |
Example use of this wrapper:
UTIL_ClearVariables(->myLong;->myPict;->$myArray;->$myBLOB;-><>myDate;-><>myTime) |