INCLAN: external: Difference between revisions

From CYANA Wiki
Jump to navigation Jump to search
No edit summary
 
Line 6: Line 6:


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.
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

Latest revision as of 15:44, 13 August 2009

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