[futurebasic] Re: Break ... Until

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1997 : Group Archive : Group : All Groups

From: Bowerbird@...
Date: Sat, 27 Dec 1997 12:35:50 -0500 (EST)
'   peter-

'   >   The FB manual says that 
'   >   HANDLEEVENTS does what its name suggests, 
'   >  it handles events.  
'   >   Why would I not believe the manual.
'   >   i expect HANDLEEVENTS to handle events.

'   it does -- _if_ it occurs within the program stream.
'   the problem is that you get stuck in an infinite loop
'   inside "fn beeper", and never return to "handleevents".
'   (you can't expect it to work if it's not encountered!)


'   >   Get _my_ drift!

'   it sounds like you're frustrated...

'   to an extent, that's understandable...

'   but still... you asked for help, and you got it...   
'   several people told you the error in your thinking/code,
'   and suggested many ways you could program around it.

'   it's easy to bang your head against the wall
'   and scream at how stupid the compiler is,
'   but it doesn't do anything for you, except 
'   give you a headache and make you hoarse.

'   my suggestion:  take the solution and run...

'   -bowerbird

'   p.s.  here's your code, working just fine...

GLOBALS
DIM g_x
DIM g_program_ends
DIM g_key_record;16
g_x=0
g_program_ends=0
WINDOW 1
END GLOBALS

LOCAL FN beeper
  DO
    CALL GETKEYS(g_key_record)

    'note:  following line is long & will probably wrap...
    LONG IF FN BITTST(#@g_key_record,40) AND FN BITTST(#@g_key_record,48)

      g_x=1
      g_program_ends=1
      PRINT "command-period pressed!"
    XELSE
      BEEP
      PRINT "beep!"
    END IF
  UNTIL g_x=1
END FN

LOCAL FN handle_break
  PRINT "break handler routine..."
  g_x=1
  g_program_ends=1
END FN

LOCAL FN dotimer
  FN beeper
END FN

ON BREAK FN handle_break
ON TIMER(2) FN dotimer
DO
  PRINT "handleevents encountered..."
  HANDLEEVENTS
UNTIL g_program_ends
DELAY 500