Contents Previous Next Subchapters

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

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

Tutorial
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
     end
     print f
and at the O-Matrix prompt you enter
     clear
     function f() begin
          return 2
     end
     include TEMP.OMS
O-Matrix will respond
     1
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
     2
because the f within TEMP.OMS is no longer visible.