INCLAN: external: Difference between revisions

From CYANA Wiki
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:
Usage: eval ''variable'' = ''expression''
== Synopsis ==
      show ''variable'' ...
      set ''variable'' ...
      set ''variable'' = ''value''
      unset ''variable'' ...
      ''variable'' = ''expression''
      ''variable'' := ''expression''
      external ''variable'' = ''expression''
      external ''variable'' := ''expression''


The "eval" statement evaluates the Fortran-77 ''expression'' and assigns the
'''external''' ''variable'' = ''expression''
result to the ''variable''.


The statement "show" without parameters lists the names and values of all
== Description ==
global variables that do not have the value "NULL"; with parameters, "show"
lists the names and values of the given variables. Global variables that are
hidden by a local variable with the same name are identified by the attribute
"hidden".


The statement "set" without parameters lists the names and values of all
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.
variables that do not have the value "NULL"; with parameters, "set" lists
the names and values of the given variables. In contrast to "show", local
variables are listed too.


"set ''variable'' = ''value''" gives the variable ''variable'' the string value
== Examples ==
''value''.


The statement "unset" the given variables. System variables cannot be unset.
command swap a b #Command to swap two variables
 
  var x y #Declare two local variables, x and y
"''variable'' = ''expression''" and "''variable'' := ''expression''" are shorthand
  x=$external(‘$a’) #Get value of external variable with name $a
notations for "eval ''variable'' = ''expression''" and "set ''variable'' =
  y=$external(‘$b’) #Get value of external variable with name $b
''expression''", respectively.
  external $a=y #Assignment to external variable with name $a
 
  external $b=x #Assignment to external variable with name $b
"external ''variable'' := ''value''" or "external ''variable'' = ''value''" assign
end
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.
x=10; y=5
This command can be used to return values from a macro to the calling macro.
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