3. Statements : OpenROAD Language Statements : Initialize Statement
 
Share this page                  
Initialize Statement
This statement declares local variables and local procedures and performs any specified start-up operations for a frame, field, or userclass script. This statement also declares local procedures for a user class script.
This statement has the following syntax:
initialize [([parameterlist])] =
[declareblockwithprocedures]
beginendblock[;]
You can use the initialize statement to:
Declare local variables for a frame or user class
Execute any start-up operations that you specify for a frame or user class
The parameterlist can be specified only in an initialize statement for a frame script, not in a script of a field or user class. Parameters are local variables that can be specified as parameters on a callframe, openframe, or gotoframe statement. For more information about passing parameters, see:
Callframe Statement (see Callframe Statement)
Openframe Statement (see Openframe Statement)
Gotoframe Statement (see Gotoframe Statement)
The declare block can include variables or procedures. For more information, see DeclareBlockWithProcedures (see DeclareBlockWithProcedures).
All field and menu item variables that you named in the visual development environment when you created the frame are automatically declared and cannot be redeclared in the initialize section.
Also, you cannot use the initialize statement in a procedure. Local variables for a 4GL procedure are declared by the procedure statement. See the procedure statement (see Procedure Statement) for information about declaring local variables in 4GL procedures.
The initialize statement is optional, but when you use it, it must be the first statement in the frame, field, or user class script.
OpenROAD executes the initialize statements in a user class script or a frame script and its field scripts before initializing and displaying a frame or using a user class. Thus you can use the initialize statement in a frame, field, or user class script to execute any start-up operations that you want to perform before the frame is displayed or before the user class methods or attributes are accessed. However, because the frame's form is initialized after the initialize statement completes, some actions, such as setting the HasDataChanged attribute, have no effect if performed by the initialize statement.
The initialize statement in a frame script is executed before the initialize statements in field scripts for the frame. Similarly, the initialize statement in a composite field's script is executed before the initialize statements in field scripts for children of the composite field.
The begin and end keywords define the initialize statement block that contains the statements defining the start-up tasks for that frame.
Declare local variables and forward references to local procedures in the declare section of the initialize block (see DeclareBlockWithProcedures). Local procedures declared in the declare section must have a corresponding procedure statement in the same script. If a declare block is not followed by a begin block of initialization statements, enddeclare is required at the end of the local variable declarations in the declare block.
Note:  Notes:
If you define global variables that map to user classes whose creation triggers constructors directly or indirectly, these will trigger before your starting component is launched, and the behavior of your application will be undefined and cannot be supported. If you need a global variable that references such a user class, declare the global variable default null, and assign the relevant object to it during application startup. In general, the execution sequence of constructors in user class/datatype variables declared in the same scope is undefined. You must ensure that there are no dependencies between such constructors.
The posting of userevents (using SendUserEvent) within the initialize block of a user class is unsupported.