BW> Given the trouble in transferring variable values from one sub
BW> procedure to another I find that the odd GOSUB within a program
BW> still has a place.
BW> A label on the line prior to an input statement, which in turn is
BW> followed by a simple trap containing a 'GOTO label' if the input
BW> condition is not met, can be very useful. The program repeats the
BW> input request until the conditional statement requirements have
BW> been met. No spaghetti involved.
Heck, if you need to transfer a variable value to
several procedures, COMMON SHARED is very useful.
I use DO: LOOP for that. Let's face it:
DO | Again:
k$ = INKEY$ | k$ = INKEY$
LOOP UNTIL LEN(k$) | IF LEN(k$) = 0 THEN GOTO Again
do exactly the same thing. If they get long and
involved, the DO: LOOP is easier to read. Of course,
the GOTO _could_ be indented, too. I compared
programming to writing letters and I believe that
applies here, also: different people have different
styles. The above are two styles that yield the same
result. That last line could also read:
IF NOT LEN(k$) THEN GOTO Again
Is one "more correct" than the other? The anti-GOTO
purists may think so, but the computer isn't going to
care!
My main objection with GOTO is that you then have
to hunt for the target. GOSUB is worse: you also have to
find the source. SUBs and FUNCTIONs can be found with
F2 and you return to the CALL location when you F2 back
to the calling procedure. Unless you are trying to
find it on a print-out!
FIDO: Bill White @ 1:135/110 (Miami)
InterNet: bill.white@110.sunshine.com
* SLMR 2.1a * Great minds are programmed alike!
--- Maximus 2.01wb
---------------
* Origin: Miami Amateur Computer Club BBS/USR Courier V.E (1:135/110)
|