/* GUIBEGIN WINDOW , 146, 188, 165, 63, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , User abort example FONT 8, 400, MS Shell Dlg PUSH 21, 18, 40, 14, TABSTOP, , StartLoop, , Start loop DEND GUIEND */ /* An example of allowing the user to abort a lengthy loop. */ OPTIONS "C_CALL LABELCHECK" NUMERIC DIGITS 10 LIBRARY rexxgui GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') Again: DO FOREVER GuiGetMsg() CATCH SYNTAX CONDITION('M') SIGNAL Again FINALLY GuiDestroyWindow() END RETURN /* Called by Reginald when the user clicks on our "Start Loop" button */ WM_CLICK_StartLoop: /* Let's do a lengthy loop. In fact, we'll just do a forever loop. * In order to let the user abort this, we're going to pop open a * child window (using the child layout script, childabort.rex). It * has a TEXT control to which we can display status messages. We'll * just display a count of every 100 loops. It also has a Cancel button * the user can click upon to abort this loop. When the user clicks * this button, the child script calls GuiWake with the signal "ABORT". */ /* First, let's open the child window as a modal window. */ CreateObject("ChildAbort.rex",,, "My title") /* Initially, the child window has not set GUISIGNAL yet */ GuiSignal = "" count = 0 DO FOREVER /* Update the status message if 100 loops have passed */ IF count // 100 == 0 THEN ChildAbort~ShowMessage(count "loops have passed.") count = count + 1 /* Call GuiGetMsg to allow us to check if the user has interacted * with the window. But use a "CLEAR" operation, so GuiGetMsg doesn't * pause our script if he hasn't done anything. */ GuiGetMsg("CLEAR") /* Did he click on the "Cancel" button? If so, the child script * called GuiWake, and so GuiSignal was set to "ABORT". */ IF GuiSignal == "ABORT" THEN LEAVE END /* DROP the child script to close its window, and free the object */ DROP ChildAbort RETURN