[futurebasic] Re: [FB] CPU cycles

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2008 : Group Archive : Group : All Groups

From: Jay Reeve <jayreeve@...>
Date: Wed, 9 Apr 2008 19:55:10 -0500
Stu,

Your intent was clear, but your code will call HandleEvents 999 out  
of 1000 loops!
I think you meant         if myCount MOD 1000 == 0 THEN HandleEvents

MOD is a relatively slow operator to use in every loop, so I would  
probably choose something like this:

IF myCount >= 1000 THEN myCount = 0 : HANDLEEVENTS

Another cute method, definitely not RP-approved, calls handleevents  
every 256 loops:

DIM myCount AS BYTE

DO
       ...
       myCount++ : IF myCount == 0 THEN HANDLEEVENTS
       ...
UNTIL done

Do you see how it works? :-)

   e-e
   =J= a  y
    "

On Apr 9, 2008, at 5:35 PM, Stu Cram wrote:
> e) If a calculation routine were particularly long, then perhaps a  
> conditional HANDLEEVENTS could be inserted there to check  
> occasionally.
> ex    myCount = 0
>       doneCalc = _false
>       DO
>         ....
>         myCount++
>         if myCount MOD 1000 THEN HandleEvents
>         ....
>       UNTIL doneCalc = _true