Programming Guide : Programming Frames : How You Can Determine If a Frame Is Being Initialized
 
Share this page          
How You Can Determine If a Frame Is Being Initialized
The setting of the ProcExec.InInitialize attribute indicates whether a frame or ghost frame is in the process of being initialized (still executing the INITIALIZE block). If execution is currently within or as a result of being in the INITIALIZE block, this attribute is set to 1; if not, it is set to 0.
InInitialize lets you take advantage of code modularity, allowing common 4GL routines to adapt to the context from which they are called. You can check InInitialize within any 4GL object that can be run—frames, procedures, userclass methods, senduserevent statements, and userclass constructors—to determine whether the calling context was triggered within an INITIALIZE block.
The following is an example script that uses InInitialize for a frame:
/*
** Demonstrate the ProcExec.InInitialize attribute
*/
initialize() =
declare
    nc = uc1;                     // Declare a userclass object
    localp = procedure;           // Declare a local procedure
enddeclare
{
    /*
    ** We are in the frame's initialize section. Calls to userclass methods, 
    ** 4GL procudures, local procedures, userevents, field initializers, and
    ** userclass initializers will return 1 as a value for 
    ** curframe.ininitialize.
    */
    curframe.trace( text = 'Starting frame initialize: ' 
                                + varchar(curframe.ininitialize) );
    nc.m1();                     // Call a userclass method
    callproc localp();           // Call a local procedure
    callproc proc1();            // Call a 4GL procedure
    curframe.senduserevent( eventname = 'ev1' );  // Send a userevent
}
on click MyButton = 
{
    curframe.trace( text = 'Clicked button myButton: ' 
                                + varchar(curframe.ininitialize) ); 
    /*
    ** After clicking MyButton, calls to userclass methods, 
    ** 4GL procedures, local procedures, userevents, and 
    ** userclass initializers will return 0 as a value for 
    ** curframe.ininitialize.
    */
    curframe.trace( text =  'In Button Click: '
                                + varchar(curframe.ininitialize) );
    nc.m1();                     // Call a userclass method
    callproc localp();           // Call a local procedure 
    callproc proc1();            // Call a 4GL procedure
}
on userevent 'ev1' =
{
    curframe.trace( text =  'In userevent ev1: '
                                + varchar(curframe.ininitialize) );
    nc.m1();                     // Call a userclass method
    callproc localp();           // Call a local procedure
}
 
procedure localp() =
{
    curframe.trace( text =  'In local procedure localp: '
                                + varchar(curframe.ininitialize) );
    nc.m1();                     // Call a userclass method
}