Contents Previous Next Subchapters

Creating Global Variables From Temporary Ones
Syntax global new variable = existing variable
See Also global and print
Abbreviation g
Menu Command Debug | Global . . .

Description
Defines a new global variable and assigns it the current value of an existing variable. This makes the current value of the existing variable available once control returns to the O> prompt. (Some values are local to a specific environment and are not available when control returns to the O> prompt.)

Example
If the file TEMP.OMS in the current working directory contains
     clear
     function f(x) begin
          y = x^2
          stop
     end
     f(seq(10))
and at the O> prompt you enter
     include TEMP.OMS
O-Matrix will activate the Debugger window with that arrow pointing to the stop statement. If you then enter
     global z = y
     continue
O-Matrix will return control to the O> prompt. If you then enter
     gplot(z)
O-Matrix will plot the global variable z, which has the same value as the temporary variable y had at the stop statement.