Hi all. I have created a window with a progress bar and a "Cancel" button in it. The intent is to allow the user to stop program execution. I'm getting an error when I press cancel though, and do not know how to resolve it. A simplified version of my script is below.
Names Default to Here(1);
//Define progress window
pwin = NewWindow("Progress",
SB_L = SpacerBox(Size(0, 15), Color("Green")),
ButtonBox("Cancel",
pwin << Close Window;
Stop();
)
);
//Sample Loop
For(i=1, i<=10, i++,
SB_L << Size(i*10, 15); //update the progress bar
Wait(1); //rest of loop
);
If I press Cancel while the loop is running, I get the following error:
deleted object reference: SB_L << Size(i * 10, 15) in access or evaluation of 'Glue' , pwin = New Window("Progress",
SB_L = Spacer Box(Size(0, 15), Color("Green")),
Button Box("Cancel",
pwin << Close Window;
Stop();
)
); /*###*/For(i = 1, i <= 10, i++,
SB_L << Size(i * 10, 15);
Wait(1);
) /*###*/;
When the cancel button is pressed, my expectation is that the progress window should close, and then execution should stop. But it appears to continue on for at least one iteration, and fails at the SB_L << Size() line in the For loop. It fails because the progress window has closed and SB_L has been deleted, but I'm confused why this line is getting executed if the Stop() command was issued?
Am I correct that program execution is continuing even after my Stop() command? How can I prevent the execution of the SB_L << Size() command after the Cancel button has been pressed?
Details:
JMP Pro 15.2.1
Mac OS Big Sur v11.6
Thanks.