2. Structuring an Application : Scope of Frames, Procedures, Variables, and Constants : 4GL Procedures
 
Share this page                  
4GL Procedures
The scope of 4GL procedures and variables depends on how and where they are created. 4GL procedures and variables created in OpenROAD are globally accessible to other application components. Likewise, all components in an application are available to other applications that include it.
However, 4GL procedures and variables declared and defined in a 4GL script are local in scope. Field variables, declared automatically when you create a field on a form, are also local to the frame.
Local variables are declared in the DECLARE section of the initialize block of a frame, field, or 4GL procedure, as are forward references to local procedures. Variables declared within the parentheses of a frame's or procedure's initialize block are parameters, visible outside the current frame or procedure. Local procedures are defined at the end of a script, after all event blocks or method definitions.
For more information about the syntax for variable and procedure declaration, see the Programming Guide.
The following table describes the scope and lifetime of local variables and procedures:
Where Declared
Scope
Lifetime
(of Variables)
Frame script
Entire frame script and all associated field scripts, including all initialize blocks, event blocks, and local procedures
Life of frame
Field script for scalar field
Entire field script, including its initialize block, event blocks, and local procedures
Life of frame
Field script for composite field
All field scripts for the composite field and for all fields contained within it, including all initialize blocks, event blocks, and local procedures in these field scripts
Life of frame
Event block
(variables only)
Event block
Life of event block
Local procedure
(variables only)
Local procedure
Life of local procedure
Global 4GL procedure script
Entire 4GL procedure script, including all of its local procedures 
Life of global 4GL
procedure
User class method
(variables only)
Method
Life of method