Folders and Scope

This illustrates variable scope with regards to folders

Example workspace: Folders and Scope Example Workspace

The workspace linked above contains several data tables and folders. A folder can be created the same way you create a data table, except you select Add Folder instead of Add Data Table.

A folder behaves the way you think it would, basically added as a path prefix when accessing a child table. This workspace shows the general scope rules used in Apogee.

There are four folders in this example, the top level folder in the workspace, called Model, two child folders inside of Model, called folder1 and folder2, and one folder inside of folder1, called folder11.

Each of these folders contains a table x which contains a string telling which folder it is in.

Each folder also contains some test tables, in which the formula simple returns a variable named x, possibly with a path prefix.

The following rule is used to locate a variable:

  • When a variable is access from a formula of a given table, that variable (table) is looked for inside the folder of the table whose formula we are reading.

  • If the variable (table) is not found in the local folder, parent folders are checked for the variable, sequentially.

  • In order to access a table from a child folder, a prefix on the name must be used giving the folder path to the table.

You can experiment renaming (or deleting) the table called x in a given folder and see who this effects the test tables.

Last updated