Scope Level | How Declared | Extent of Existence |
---|---|---|
Public | Public X The data type can also be specified after “As”. Public X As Object | The variable is visible to all scripts in the process or transformation, and all sub-processes in the process, and technically in all parent processes. In other words, at runtime, any script module has access to the variable. This scope is denoted by declaring the variable PUBLIC. |
Private | Private X Global X The data type can also be specified after “As”. Private X As DJImport | The variable is visible to all scripts in the process or transformation, but is not visible outside the executing process or transformation. This scope is denoted by declaring the variable PRIVATE or GLOBAL. Note: Originally there was only GLOBAL scope, we later added PUBLIC and so renamed GLOBAL to PRIVATE (while still accepting GLOBAL to mean PRIVATE). |
Module | Dim num as integer Function A ... End Function Function B ... End Function | Variables with MODULE scope are available anywhere within the single script expression. For example, in a target field mapping expression, if you declare a variable, it is visible within that mapping expression, but not to any other mapping expressions. |
Local (default) | Function Y Dim X End Function | Variables with LOCAL scope are visible only within the function they are declared in. You can use the DIM keyword to declare a variable within the function to give it a LOCAL scope. Note: If Option Implicit is on (in other words, Option Explicit is off) and you simply reference a variable, then it is scoped as if the previous statement was a “DIM variable”, in other words LOCAL if used within a function definition, otherwise MODULE scope. |