[futurebasic] Re: Errors in Loops

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

From: Joe Kovac <locality@...>
Date: Fri, 5 Jun 1998 12:06:46 -0400
>How do you best handle errors in a loop when the loop may call a
>function many times? Calling an error checking FN in the loop can result
>in the user getting pasted with many many dialogs. Checking the error
>flag after the loop will not catch a single error in the middle that was
>later reset by a successful call.

I'd do something like this:

LOCAL FN Something (X%)
  Counter% = 1 : Err% = 0

  DO
    Err% = FN SomethingElse (Counter%)
    INC (Counter%)
  UNTIL (Counter% > X%) or (Err% <> 0)

  LONG IF (Err% <> 0)
    FN HandleErr (Err%)
  END IF
END FN = Err%

You may or may not want to handle the error in the function itself.

Hope that helps,
Joe