Refreshing Windows and Window Persistence<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi. I have an expression that first creates a modal notification window, and upon hitting OK, it creates a second, edit window. In the edit window, there's a Refresh button that closes the window and re-executes the original expression. When I hit "Refresh", the edit window closes as expected, and the modal notification window appears again. However, the second iteration of the edit window appears with a "2" appended to its name ("editwin 2") even though the original editwin already closed. Furthermore, the << On Close script that is supposed to immediately run when the edit window is closed the first time does not run until after the second instance of the notification window is closed and the second instance of the edit window is about to open. It seems like although the edit window is closed, it persists in the memory until the next instance of the edit window appears.
Does anyone have a good explanation for this behavior, and more importantly, what's the workaround?
Thanks.
Names Default To Here( 1 );
Delete Symbols();
editwin.expr = Expr(
BB1 = ButtonBox("ok",
Window("editwin") << Close Window;
);
BB2 = ButtonBox("Refresh",
Window("editwin") << Close Window;
editwin.expr;
);
modwin = New Window("modwin", << Modal,
TextBox("I'm a notification window"),
ButtonBox("OK", Write("Closing modwin\!N"))
);
editwin = New Window("editwin",
TextBox("I'm an edit window"),
BB1, BB2
);
editwin << On Close(Write("Closing editwin\!N"));
editwin << Set Window Size(300, 200);
);
editwin.expr;
Re: Refreshing Windows and Window PersistenceJust offering this code in case it gives you a different approach to the problem you are trying to solve
Names Default To Here(1);
Do Edit Window = Function({},{Default Local},
nwEdit = New Window("editwin", <<Modal,
TextBox("I'm an edit window"),
ButtonBox("OK" ),
);
If (nwEdit["Button"]==-1,
retVal = 1
,
retVal = 0
);
retVal
);
nw = New Window("modwin", <<Modal,
<< On Validate(
Do Edit Window()
),
TextBox("I'm a notification window"),
ButtonBox("OK", Write("Closing modwin\!N");)
);
Re: Refreshing Windows and Window Persistenceyou are correct, my work around does not cix the window nwaming issue, but it does remove the dependency on the window name. jJMLP Jmp passes window closing off to the operating system and therefore it looses absolute control of when the window actually gets closed
Re: Refreshing Windows and Window PersistenceInteresting. I'm using JMP 11.1.1 for Windows (64bit). I'm not prepared to dismiss the problem yet as a 11 vs 12 issue or Mac vs Windows issue though. At any rate, I still need to find a workaround for my current config.
Re: Refreshing Windows and Window PersistenceUnfortunately your script does not prevent renaming of the window. I tried and get the exact same behavior.
Re: Refreshing Windows and Window PersistenceFYI, I tried the script in JMP 12 for Mac and I did not see this problem; editwin was named editwin every time, no automatic numbering occurred.
However, in JMP 12 for Windows I was able to reproduce the problem: editwin 2, editwin 3 etc. are generated after every refresh. No idea why.
Txnelson approach presents a good workaround
Re: Refreshing Windows and Window PersistenceI was not able to solve the window naming issue. It appears that JMP holds the name in reserve for the duration of the execution of a given EXPR. However, the code below removes the concern over the window name, by taking all actions on the window's handle, rather than the window's name:
Names Default To Here( 1 );
Delete Symbols();
editwin.expr = Expr(
BB1 = ButtonBox("ok",
editwinx << Close Window;
);
BB2 = ButtonBox("Refresh",
editwinx << Close Window;
editwin.expr;
);
modwin = New Window("modwin", << Modal,
TextBox("I'm a notification window"),
ButtonBox("OK", Write("Closing modwin\!N"));
);
editwinx = New Window("editwin",
TextBox("I'm an edit window"),
BB1, BB2
);
editwinx << On Close(Write("Closing editwinx\!N"));
editwinx << Set Window Size(300, 200);
);
editwin.expr;