Loading...
 

Scope

Scope and visibility of the language elements of InstantView®

Variables, procedures, messages, modules, and window objects have a name (identifier or identifier).
The "visibility" of an identifier determines in which parts of the program the identifier can be used to refer to what it designates, and how ambiguities resulting from the assignment of identical names are resolved.
InstantView® program code is structured by modules.
The scope and visibility of variables, procedures and window objects is determined by the modules. (Example)
This does not apply to messages - they are intended as the only means of communication across module boundaries and therefore have global validity.

  • Module
    The name of a module is globally known and must therefore be unique.
  • Variable
    are defined within a module and only known there.
    Exception: variables agreed upon in the GLOBAL module or with Statement GlobalVar. Global variables are visible in all modules as long as they are not hidden by a local variable with the same name.
  • Procedures
    Procedures described with Define are only known within a module.
    Exceptions are also procedures that have been defined in the GLOBAL module: These can then be called in all modules as long as no (local) statement with the same name exists there.
  • Window objects
    Child objects always refer to a parent window. Windows are only known within a module. Again, the exception of the GLOBAL module applies: Windows of this module can be referred to with the corresponding InstantView® statements. However, a local window with the same name has priority, i.e. it covers a globally known window.
  • Messages
    are known system-wide. A unique name must be assigned for each message.

It is certainly not a good style to give the same names to variables, procedures and messages.
But this can happen by mistake. And that is why the following simple rules are given here:

  • Modules, messages, and window objects each have their own independent namespace.
    In principle, it is permitted to assign the same name to a module, a message or even a window object. And it does not matter if this is also the name of a variable or a statement.
  • In the syntax of InstantView®, calling a variable is similar to calling a statement; both therefore share a common namespace.
    A variable "hides" a procedure with the same name.
    However, the order of the agreement plays a role - see example.