[futurebasic] Re: unhappy with loops

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

From: MattBeedle@...
Date: Tue, 2 Dec 1997 20:04:40 -0500 (EST)
Here is a code.
If the mouse button is not down then you will hear no beep.
This loop will not execute 1 time if the conditions are false.

WHILE FN BUTTON
  BEEP
WEND

In this code you will not hear a beep either.

x = 2
WHILE x < 1
  BEEP
WEND

This will beep

x = 0
WHILE x < 1
INC(x)
  BEEP
WEND

>The FOR loop unhappiness
>------------------------
>ZBasic and FB made a poor choice in implementing FOR loops, such that the
>loop body is _always_ executed at least once, regardless of the start, end
>and increment values. To allow the body to be skipped we must bracket the
>loop as shown:-
>
>LONG IF last%>=first% ' else we want to skip the loop
>   FOR j% = first% TO last%
>    .. do stuff
>   NEXT j%
>END IF
>
>FOR loops in BASIC are officially supposed to be implemented such that the
>body can be executed zero times if appropriate. Some variants of BASIC got
>unhappy loops in the days of tiny interpreters, which were too stupid to
>follow the language definition. The only language with an officially
>unhappy loop was FORTRAN. The late lamented MS QuickBasic did it right. How
>about FBIII?
>
>The LONG IF nonsense
>--------------------
>Ever felt embarrassed showing your source code to another programmer? The
>LONG IF, inherited from ZBasic, curls my toes by its ineptness:-
>
>LONG IF flagSet
>  .. do stuff
>XELSE
>  .. do other stuff
>END IF
>
>Those other programmers snicker at the silly syntax and ask "Why LONG? Why
>no THEN after LONG IF? Why XELSE? Why no ELSEIF?..."
>
>In MS QuickBasic you could write, with no perceptible strain or discomfort:-
>IF flagSet THEN
> .. do stuff
>ELSEIF tr%=2 THEN
>  .. do other
>ELSE
> .. yet different
>END IF
>
>How about FBIII? Is it going to cast off the ugly and inflexible LONG IF?