How to detect if a caption box has been closed?Hi!
I have a script that loops through the cells of the data and does some data processing.
To give the user an idea of what cell it is currently processing, I add this line:
Caption("Processing "||Char(i)||" out of "||Char(Nrows(dtmed))||" Cells...");Anyway, if I close the caption, the script just proceeds to the next iteration. What I want is for the script to terminate if the user closes the caption box. Maybe there is some function that will give me the status of the caption box if it were closed?
Anyway, last resort is this thread:
https://community.jmp.com/t5/Discussions/Jsl-How-can-i-stop-a-script-with-a-button/td-p/6787
Although, I am apprehensive of having two windows (one caption box and one window box) just to have an escape button.
Thanks for the help.
Re: How to detect if a caption box has been closed?You could consider using 'OnClose()' to do the housekeeping so long as you are keeping track of the tables:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
nw = NewWindow("Using 'On Close'", << onClose(onCloseBlock), TextBox("Close Me"));
onCloseBlock =
Expr(
Print("Closing table "||(dt << getName));
Close(dt, NoSave);
);Re: How to detect if a caption box has been closed?@ian_jmp
I made it like this:
CheckBlock=Expr (
stattb<<SETTEXT></SETTEXT>Somehow, the Cancel button isn't doing its job, I think I placed it wrong within the script.
Hm, unfortunately, abnormal abort by (X) button leaves plenty of invisible data tables.
Still checking how to deal with it.
Thanks for the help.
Re: How to detect if a caption box has been closed?Thanks! Let me check how I can adapt this to my current script.
Re: How to detect if a caption box has been closed?Looks like you can't send messages to 'Caption()' to manipulate it.
Adapting what's in the other thread, you could try something like:
NamesDefaultToHere(1);
nw = NewWindow("Stop script",
tb = TextBox("Press 'Run'... \!n"),
bb1 = ButtonBox("Run", runScript),
bb2 = ButtonBox("Cancel", stopFlag = 1),
);
nw << setWindowSize(150, 120);
runScript =
Expr(
bb1 << enable(0);
stopFlag = 0;
for(i=1,i<=100, i++,
Wait(1);
if(stopFlag,
// Stop . . .
nw << closeWindow;
Print("Stopped after "||Char(i)||" seconds.");
Stop(),
// Else update display . . .
tb << setText("Counted for "||Char(i)||" seconds.")
);
);
nw <<CLOSEWINDOW></CLOSEWINDOW>