INCLAN: external: Difference between revisions
Jump to navigation
Jump to search
(Created page with 'Usage: eval ''variable'' = ''expression'' show ''variable'' ... set ''variable'' ... set ''variable'' = ''value'' unset ''variable'' ... ''vari…') |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== 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. | |||
the | |||
== 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 14: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