Contents Previous Next Subchapters

Local Variables
Syntax local variable = value
See Also assignment , const

Creates a new variable that has file scope and assigns it a value.

Local variables are limited in scope to the files in which they are defined. Suppose the file TEMP.OMS contains the commands
     local y = 7
     print y
and you enter the commands
     y = 8
     include TEMP.OMS
O-Matrix will respond
because the value of y within the file TEMP.OMS is 7. If you continue by entering
     print y
O-Matrix will respond

If a function is defined after a local variable, the local variable is visible within the function. This is different variables that are not defined as local because they require a global statement to make them visible within a function.

If the file TEMP.OMS contains
     local z = 10
     function f() begin
          print z
and you enter
     include TEMP.OMS
O-Matrix will respond

A local statement can only appear in a file (not at the command line) and it cannot be inside of any function.