INCLAN: external

From CYANA Wiki
Jump to navigation Jump to search

Synopsis

external variable = expression

Description

Assigns a value (i. e. a string) or the result of an expression to an external (non-local) variable even if a local variable with the same name exists. This command can be used to return values from a macro to the calling macro.

Examples

command swap a b	#Command to swap two variables
  var x y	#Declare two local variables, x and y
  x=$external(‘$a’)	#Get value of external variable with name $a
  y=$external(‘$b’)	#Get value of external variable with name $b
  external $a=y	#Assignment to external variable with name $a
  external $b=x	#Assignment to external variable with name $b
end

x=10; y=5
print "Before swap: x = $x, y = $y"
Before swap: x = 10, y = 5
swap x y
print "After swap : x = $x, y = $y"
After swap : x = 5, y = 10