Function Scopes

Function scopes, like variable scopes, control how visible a function is to functions in other files in the project. There are three scopes and if a scope is not defined then the default is always GLOBAL.

Function scopes form a hierarchy, where functions in the same scope and higher scopes are visible to a calling function, but functions in child or cousin scopes are not visible. A example hierarchy for a project might look like this:

  • GLOBAL [Defined in any circuit code file or any device file]
    • INTERNAL [Defined in any circuit code file (Globals.xje and AdcTests.xje)]
      • LOCAL [Defined in Globals.xje]
      • LOCAL [Defined in AdcTests.xje]
      • Other circuit code files...
    • INTERNAL [Defined in I2C EEPROM 5-Pin SOT.xje and its additional code files, I2C EEPROM.xje and IIC.xje]
      • LOCAL [Defined in I2C EEPROM 5-Pin SOT.xje]
      • LOCAL [Defined in I2C EEPROM.xje]
      • LOCAL [Defined in IIC.xje]
    • INTERNAL [Defined in LED.xje (has no additional code files)]
      • LOCAL [Defined in LED.xje]
    • Other device files...

Global Functions

Global functions are visible everywhere in the project, and so should be used if the code needs be called from other parts of the project.

In a Circuit Code File, GLOBAL functions can be:
In a Test Device File and its Additional Code Files, GLOBAL functions can be:
  • Called from any part of the same device file or its associated additional code files.
  • Used as a Test Function.
  • Called from a circuit code file function using the CALL keyword.

Internal Functions

If a function does not need to be called by other parts of a project, it should be set to INTERNAL.

In a Circuit Code File, INTERNAL functions can be:
  • Called by any other circuit code file.
In a Test Device File and its Additional Code Files, INTERNAL functions can be:
  • Called from the same device file or its additional code files.

Local Functions

For functions that will only be called by other functions in the same file, LOCAL should be used.

In a Circuit Code File, LOCAL functions can be:
  • Called by any function in the same file.
In a Test Device File and its Additional Code Files, LOCAL functions can be:
  • Called by any function in the same file.

Functions in lower scopes cannot have the same name as functions in higher scopes, with the exception that functions in Test Device Files may have the same name as GLOBAL Circuit Code File functions, and so make those global functions inaccessible in the device file.