[futurebasic] Re: [FB] HandleEvents, Random seed and PG:PRO

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1999 : Group Archive : Group : All Groups

From: Sean -G3- <mclaughlin@...>
Date: Fri, 25 Jun 99 16:13:11 -0400
>Question 1
>
>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?

I don't use PG, I just write the code the ole-fashioned way. But yes, you 
could use handleevents in nested FOR loops for that purpose. Just make 
sure you have everything setup correctly. If you also use handleevents at 
some other point in your program, make sure you setup a flag so that 
events are handled correctly (and differently) for each point in the 
program.

All handleevents does is:
-Checks for events such as menus, mouse clicks, key-presses
-Allows other program to "do their thing"
-Routes program control to the your event-handler function
So you can put it wherever you want.

You could also use (with no handleevents):
DO
'insert your code
UNTIL LEN(INKEY$) or FN BUTTON
fn button is a pre-defined function which returns a true (positive) value 
when a mouse click occurs.

Or even better, you could do this:

CLEAR LOCAL
LOCAL FN doEvents
  DIM theEvent
  
  theEvent={EVENT}
  SELECT theEvent
    CASE _nullEvt
      
     SELECT gProgramStep
       CASE 1
          'do some stuff
       gProgramStep = 2
       CASE 2
          'do some more stuff, etc
      END SELECT
  END SELECT
END FN

CLEAR LOCAL
LOCAL FN doMouse
  DIM mouseEvt, windID
  
  mouseEvt=ABS(MOUSE(0))
  
  SELECT mouseEvt
    CASE _click1, _click2, _click3
      END
  END SELECT
  
END FN
'--------------------------
FN initialize

ON EVENT FN doEvents
ON MOUSE FN doMouse

DO
  HANDLEEVENTS
UNTIL gProgramEnds