Consultor Eletrônico



Kbase 18075: initialization of persistent run smart-objects
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/13/1998
initialization of persistent run smart-objects

Description:
============

Initialization of smart-objects run persistently from inside another
window or program. An easy way to make them visible.


INTRODUCTION:
=============

There are cases when two windows are created seperately
from each other, but where the first has to run the second persistent
to do e.g. a lookup on some other kind of data or because it needs
it's internal codeblocks.

The second window (or smart-object) can then be run with
a simple RUN window2.w PERSISTENT. This will run the second window,
however it will NOT initialize it. This has to be hardcoded after the
run ... statement to get the normal behaviour.


WHY YOU NEED TO KNOW THIS:
===========================

In the main-block of each smart-object there is a small section that
initializes the object. It looks like this:

/* ********************** Main Block ************************** */

&IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
RUN dispatch IN THIS-PROCEDURE ('initialize':U).
&ENDIF


This works allright if the smartobject is run standalone, but when run
persistently from inside another object or program, the code beginning
with &IF (which is a preprosessor call) is not processed. The
initialize placed there is part of the preprocessor code and thus
ignored.

SOLUTION:
=========

Initialize the object yourself with the use of it's handle.

Suppose you have a button to run the second window (window2.w).
Then the following code will run it correctly. The advantance of
this approach is that you don't have to change any reference to
handle like CURRENT-PROCEDURE.

ON CHOOSE OF BUTTON-1
DO:

DEFINE VARIABLE my_handle AS HANDLE NO-UNDO.

RUN window2 PERSISTENT SET my_handle. /* set pointer to window */
RUN DISPATCH IN my_handle ('initialize':u).
/* to get the normal initialization of the object */
END.


REFERENCES TO WRITTEN DOCUMENTATION:
====================================

See also the THIS-PROCEDURE handle and the RUN statement
for additional information in the online help.