Definition Visibility<indexterm> <primary>Definition Visibility</primary> </indexterm> ECL code, definitions, are stored in .ECL files .ECL files in your code repository, which are organized into modules (directories or folders on disk). Each .ECL file may only contain a single EXPORT or SHARED definition (see below) along with any supporting local definitions required to fully define the definition's result. The name of the file and the name of its EXPORT or SHARED definition must exactly match. Within a module (directory or folder on disk), you may have as many EXPORT and/or SHARED definitions as needed. An IMPORT statement (see the IMPORT keyword) identifies any other modules whose visible definitions will be available for use in the current definition. The following fundamental definition visibility scopes are available in ECL: "Global," Module, and Local. "Global" Definitions defined as EXPORT EXPORT (see the EXPORT keyword) are available throughout the module in which they are defined, and throughout any other module that IMPORTs that module (see the IMPORT keyword). //inside the Definition1.ecl file (in AnotherModule folder) you have: EXPORT Definition1 := 5; //EXPORT makes Definition1 available to other modules and //also available throughout its own module Module The scope of the definitions defined as SHARED SHARED (see the SHARED keyword) is limited to that one module, and are available throughout the module (unlike local definitions). This allows you to keep private any definitions that are only needed to implement internal functionality. SHARED definitions are used to support EXPORT definitions. //inside the Definition2.ecl file you have: IMPORT AnotherModule; //makes definitions from AnotherModule available to this code, as needed SHARED Definition2 := AnotherModule.Definition1 + 5; //Definition2 available throughout its own module, only //***************************************************************************** //then inside the Definition3.ecl file (in the same folder as Definition2) you have: IMPORT $; //makes definitions from the current module available to this code, as needed EXPORT Definition3 := $.Definition2 + 5; //make Definition3 available to other modules and //also available throughout its own module Local A definition without either the EXPORT or SHARED keywords is available only to subsequent definitions, until the end of the next EXPORT or SHARED definition. This makes them private definitions used only within the scope of that one EXPORT or SHARED definition, which allows you to keep private any definitions that are only needed to implement internal functionality. Local definitions definitions are used to support the EXPORT or SHARED definition in whose file they reside. Local definitions are referenced by their definition name alone; no qualification is needed. //then inside the Definition4.ecl file (in the same folder as Definition2) you have: IMPORT $; //makes definitions from the current module available to this code, as needed LocalDef := 5; //local -- available through the end of Definition4's definition, only EXPORT Definition4 := LocalDef + 5; //EXPORT terminates scope for LocalDef LocalDef2 := Definition4 + LocalDef; //INVALID SYNTAX -- LocalDef is out of scope here //and any local definitions following the EXPORT //or SHARED definition in the file are meaningless //since they can never be used by anything The LOCAL LOCAL keyword is valid for use within any nested structure, but most useful within a FUNCTIONMACRO structure to clearly identify that the scope of a definition is limited to the code generated within the FUNCTIONMACRO. AddOne(num) := FUNCTIONMACRO LOCAL numPlus := num + 1; RETURN numPlus; ENDMACRO; numPlus := 'this is a syntax error without LOCAL in the FUNCTIONMACRO'; numPlus; AddOne(5); See Also: IMPORT, EXPORT, SHARED, MODULE, FUNCTIONMACRO