Steve Flavel a *crit : > > I have nine nested loops that generate all the possible arrangements of the > digits from 1 to 9 (9 factoral) > > To get out of these loops I use INKEY$. However I would now like to use a > button click to also break out. Can I safely use HANDLEEVENTS, within the > loop using a PG: PRO shell? > Steve, Why don't you use FN BUTTON to check is the mouse button is down? Perhaps, you might consider another technic using PG: first, dim a global variable (let's say gMouseOrKeyFlag for instance) then use the PG function pGSendNull inside the loops so that the flow of the program can be routed outside of the loop and then test in section "Action other": case _otherNullEvent if the mouse button is down or a key is pressed You can build in a few seconds an example of such a technic. 1 - Create a new project with PG (just create a window then save) 2 - Open the project in FB and add in your global file: DIM gMouseOrKeyFlag 3 - In your main file add the function below LOCAL FN doLoop DO FN pGsendNull UNTIL 1 = 2 OR gMouseOrKeyFlag gMouseOrKeyFlag = _false END FN 4 - Change your mainstart section so that it looks like this: CASE _mainStart ' ' You can open a window in PG with '"FN pGbuild(_theWindow)" ' If you change the constant name of ' the first window, you must also ' change the constant in the following ' line. gMouseOrKeyFlag = _false FN pGbuild(_windowClass1) FN doLoop BEEP:BEEP 5 - And finaly add this line in the otherNullEvent section CASE _otherNullEvent gMouseOrKeyFlag = FN BUTTON OR LEN(INKEY$) Hoping this makes sense Alain