Hi,
first, your program stops executing the END statement so it's no question
why it stops but why it does reach this line.Executing an END statement
always closes all open files.
Second, the error might be caused due to some code outtside the loop making
your code difficult to check. Using GOTO <linenumber> is possible but you
have to take care that your code will later on jump back into the loop. PDS
supports GOSUB with labels, so to get better readable and checkable code you
should use GOSUB <label> in conjunction with <label>: and RETURN to get a
better readable and checkable code structure. A still better way is to use
subroutines with SUB <subname>...RETURN.
Generally, PDS does not need line numbers at all. Forget all line numbers
and use labels, this will make your code significantly clearer and more
readable, and insert blank lines for separation to enhance readability. The
more readable your code the better checking for errors it is. Empty lines
are ignored by the compiler and therefore do not enlarge file size.
Third, it's not a good practice to add graphical files as attachment. You
can add code simply as plain text into your mail, or if you insist to add a
code file use txt format at least, this will enable us to copy out your code
for better reading, more tests, and so on, if nescessary. The included GIF
file is of poor quality and therefore harder to read than nescessary.
Your trial to understand code execution by reporting line numbers is not
very effective as you see, because it's hard to maintain variable values to
find out which conditions will branche.
For easier debugging use something like this:
MSG$ = "<code location>: <variable name> = <variable's content>
CALL DBGOUTPUT (MSG$)
:::
SUB DBGOUTPUT (M$)
PRINT M$
END SUB
Fourth, never, never change FOR...NEXT loop variables inside or outside the
loop as you do here.
If you need to change such a value use a WHILE...WEND construction with a
separate loop counter variable which can be incremented as you want and used
to exit loop.
HTH, wuez
BTW: do you still use PDS and MS DOS, or do you PDS run in a command line
window (I never tried this but it might work)?
Basic PDS 7.1
"Robert Baer" <
rober...@localnet.com> schrieb im Newsbeitrag
news:FEc1H.81519$lZ.3...@fx12.iad...
> I am having a devil of a time tying to figure out why a BASIC program
> does not work properly.
> Had been using the BASIC Professional Development System Ver 7.1
> (equivalent to Quick BASIC from DOS 6.22 daze).
>
> Inserting a bunch of debug print lines did not help much; in a
> section of the program, 6 statement lines got executed in 1,3,5,2,4,6
> order instead of the expected, listed 1,2,3,4,5,6 order.
>
> I got tired of fighting it so converted the program into a
> line-numbered version and made the obvious reference changes for GWBASIC
> DOS 3.3).
>
> Attached is a screen shot montage showing one still messy section of
> code, along with a TRON.
>
> Notice the program stops at line 530 for no good reason, and all
> files are closed.
>
> One would think that a more regimented, line-numbered program would
> behave.
>
> Help?
>
> Thanks.
>