[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Advanced Programming Structures
I must disagree also. I would never modify a FOR loop
variable since it is possible that you will never leave the
loop. I think I would rather put up with the GOTO and
the line numbers than violating a structure such as FOR.
It defeats the purpose. If you want to emulate a While/
Wend or a Repeat/Until, there are better ways.
10 X=0
20 REM do some stuff
30 IF X<>some condition then goto 20
Is similar to a Until structure since it is a post loop test
and you could write pre-loop testing as well.
10 X=0
20 IF X=some condition THEN goto 50
30 REM do some stuff
40 GOTO 20
50 REM continue
--
--
William R. Strutts - wrstrutts1@home.com - Whatever!
C'est moi! http://www.facelink.com/wrstrutts
Just hacking away...
"Keith Olson" <s p a m t r a p 0 0 7 @ y a h o o . c o m> wrote in message
tk4aadsn7hd824@corp.supernews.com">news:tk4aadsn7hd824@corp.supernews.com...
> I must disagree with you on two points:
>
> 1. Using GOTOs is *not* bad programming practice; using *excessive* GOTOs
> is. The worst I've ever come across is 5 chained GOTOs - in a *commercial*
> program (!)that I was hired to *try* to modify. I try to avoid using
GOTOs
> in Applesoft and Atari BASIC because they both use line numbers, and
> remembering where branches go can make renumbering tricky.
>
> 2. Changing programming practice for a specific purpose (i.e. to emulate
the
> DO/LOOP structure) and to add to your general programming strategy,
instead
> of doing it 'just because', *IS* good programming practice, as long as it
is
> clear and consistent. (IMHO)
>
> --
>
>
> Keith Olson
>
> ---------------------------------------------------------------------
> | For the memory of the uncompromisingly righteous is a blessing, |
> | Proverbs 10:7a |
> ---------------------------------------------------------------------
>
>
> "SoftNGui" <softngui@earthlink.net> wrote in message
> tk3qgi4kr8a1ac@news.supernews.com">news:tk3qgi4kr8a1ac@news.supernews.com...
> > This code misses the point. It tries to avoid GOTO's because they are
bad
> > programming practice. Yet at the same time, changing the for-loop
> variable
> > II within the loop is also bad programming practice.
> >
> > Keith Olson <s p a m t r a p 0 0 7 @ y a h o o . c o m> wrote in message
> > tk35h8spqrdqaa@corp.supernews.com">news:tk35h8spqrdqaa@corp.supernews.com...
> > > FOR II = 0 TO 1
> > > .
> > > .
> > > .
> > > II=1
> > > IF X=0 THEN II=0
> > > IF Y=0 THEN II=9
> > > IF Y=99 THEN II=10
> > > NEXT II
> > > IF II=10 THEN PRINT "AT BOTTOM"
> > > IF II=11 THEN PRINT "AT TOP"
> > >
> >
> >
> >
>
>