Using the same Trigger to run the same window several

Pr3ach3rman

New Member
I want to use a Button or Menu-Item to be able to run the same window multiple times.
My Problem is that the Trigger is not working until the started Window is closed. Then i am able to open it again but allways only 1 Instance.

I found one way to do this using a timer event and another one by deleting and creating the button again but ther has to be something simple.

Thanks, P3
 

Cringer

ProgressTalk.com Moderator
Staff member
How are you running the window? If you run it persistently and keep a handle for clearing up later if needs be, then I think you can run multiple instances.
 

Pr3ach3rman

New Member
1.) OpenEdge10.2B AppBuilder
2.) WinXP (5.1.2006:SP3)
3.) I have tried to work with the Trigger of the Button
Code:
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn01 wWin
ON CHOOSE OF Btn01 IN FRAME fMain 
DO:
    RUN window.w
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
4.) No Errors. I just can't run window.w a second time while the first started version of it was not closed.
 

Cringer

ProgressTalk.com Moderator
Staff member
What does this do?

Code:
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn01 wWin 
ON CHOOSE OF Btn01 IN FRAME fMain  DO:
    DEFINE VARIABLE lv-Handle AS HANDLE NO-UNDO.     
    RUN window.w PERSISTENT SET lv-Handle.
END.

You'll need a more complex way of keeping all the handles to ensure they're cleaned up later, but for now this will do to see if it helps.
 

RealHeavyDude

Well-Known Member
Running more than one window without persistent will bring you into trouble because of the one session one WAIT-FOR rule because of the following code that is standard in every window:
Code:
 /* Now enable the interface and wait for the exit condition.            */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire.    */
MAIN-BLOCK:
DO ON ERROR   UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
  RUN enable_UI.
  IF NOT THIS-PROCEDURE:PERSISTENT THEN
    WAIT-FOR CLOSE OF THIS-PROCEDURE.
END.

Heavy Regards, RealHeavyDude.
 

Pr3ach3rman

New Member
What does this do?

Code:
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn01 wWin 
ON CHOOSE OF Btn01 IN FRAME fMain  DO:
    DEFINE VARIABLE lv-Handle AS HANDLE NO-UNDO.     
    RUN window.w PERSISTENT SET lv-Handle.
END.

Nothing. I have created 2 new smart winows to try the Code above. I recieve the message i placed in the line after the Run Statement but the window is not starting. :confused:
 

RealHeavyDude

Well-Known Member
When you start a procedure (your window) persistently all that is happening is that the main block gets executed and then the procedure remains in memory until you stop it. Smart window is a term used in frameworks that are part of the Progress development license installations. There are at least 3 of them: ADM1 (introduced with Progress V8), ADM2 (introduced with Progress V9) and Dynamics (which is based on ADM2 and was also introduced with some Progress V9). Usually just running a smart object persistent doesn't do much unless you invoke the initializeObject internal procedure of it immediately afterwards. That is by design.

What happens when you execute (coded in Firefox IDE - not syntax checked ...)
Code:
RUN initializeObject IN lv-handle.

Heavy Regards, RealHeavyDude.
 

RealHeavyDude

Well-Known Member
You're welcome ...

Furthermore: When you want to stop the window, before deleting the persistent procedure you should invoke destroyObject in it because otherwise you might experience unwanted behavior as deleting the persistent procedure will just kill it no matter in which state it is - destroyObject will gracefully clean up it's state ...

Heavy Regards, RealHeavyDude.
 
Top