The containerContextDependent property specifies that references inside a stand-alone function (see Functions) are to be resolved with respect to the container (the main part) in which the function will reside after generation. This means that the declarations and imports of the container are used to resolve references during the generation process. The stand-alone function itself, even though a top-level part, does not have to import all the packages that are necessary to resolve references as long as the final container does so. For example, you can use this property when the function is used in more than one program, and variable names are resolved differently depending on the program that calls the function.
Use the containerContextDependent property with stand-alone functions only. EGL supports stand-alone functions for compatibility with programs like those created in VisualAge® Generator, where the language does not support libraries. Do not use stand-alone functions or the containerContextDependent property when writing new code.
package p;
Program pgm {includeReferencedFunctions = yes}
function main()
standaloneFunc1();
end
function functionInPgm()
end
end
DataItem intInP int end
package p2;
function standaloneFunc1 { containerContextDependent=yes }
// reference to function resolves
// because of containerContextDependent
functionInPgm();
// reference to part resolves
// because of containerContextDependent
myVar intInP;
end
function standaloneFunc2
functionInPgm(); // reference cannot be resolved
myVar intInP; // reference cannot be resolved
end
function standaloneFunc3
// reference to part resolves because
// it is qualified by the package name
myVar p.intInP;
end
| Platform | Issue |
|---|---|
| JavaScript generation | The property containerContextDependent is not supported |