Contents Previous Next Subchapters

Defining Local Functions
Syntax local function name ( arguments ) block
See Also local variables , call back commands , multiple return values

Defines a new function with the specified name that has file scope .

Local functions are limited in scope to the files in which they are defined. Suppose the file TEMP.OMS contains the commands
     local function f() begin
          return 1
     print f
and at the O-Matrix prompt you enter
     function f() begin
          return 2
     include TEMP.OMS
O-Matrix will respond
because the version of f within the file TEMP.OMS returns the value 1. If you continue by entering
     print f
O-Matrix will respond
because the f within TEMP.OMS is no longer visible.