webCOMAND

#LOCAL

Declare a local variable, or ensures that a specified variable will not continue to be available above of the current scope.  If another variable by the same name exists in the parent scope, its value will remain after the local scope exits, even if changed in the local scope.

Prototype

#LOCAL($variable[, expression])

Parameters

  • variable - The $Variable is the name of a new or existing variable to be made local (it will not be preserved in the parent scope).
  • expression - Optional cTemplate expression to be evaluated and result assigned to the variable.  If no expression is provided the variable will be unchanged (even if not set yet), but flagged to be local.

Example

Assign the global variable $EndDate in "Scope 1".  Assign a different date to the local variable $EndDate in "Scope 2".  After Scope 2 exists, $EndDate variable is referenced to output the value set in "Scope 1".

#/ Scope 1
#ASSIGN($EndDate,'2002-11-07')

#/ Scope 2
#LIST(SomeList)
    #LOCAL($EndDate,'2004-02-10')
#ENDLIST

#/ Back in Scope 1 again ($$EndDate is '2002-11-07')
$EndDate

Related

#Global