Subscript Out of Bounds Error Message

I am writing a program that reports a 'Subscript Out of Bounds' error, with an 'occurred at' line number and then, a series of 'Called From' line numbers. The 'occurred at' line number is no where near an array. To trouble shoot, I wrote a simple 6-line program and deliberately forced an array out of bounds. As expected, I got a 'Subscript Out of Bounds' error, but the 'occurred at' line number was 11, 5 lines past the END Statement??

What's going on here??


Subscript out of range error 2001

By intentionally forcing 'subscript out of range errors' in my code, I was able to find that the error line #s stated in the error message are 8 lines more than the actual occurrence, even if it is beyond the "END' statement I'm not smart enough to know why. Inducing a few other types of errors produce accurate line #s in the error statements.


Subscript out of range error 2001

Hello olejim,


Have you tried opening the program file in a text editor, other than the TB editor, to see if there are bogus lines present?

Since the only thing "new" in TB v.6 is the TB Editor, this anomaly must be being caused by that. True Basic itself is still the same as it always was.

I do not have v.6 since there is nothing new except the editor, and even so I always use a simple text editor to write and save programs since they are nothing but text files anyway.

Mike C.

BigJohn can probably explain

BigJohn can probably explain better than me, but back when I was trying to "disassemble" TRC files, I found out that the True Basic 6 editor is actually modifying the program source before calling the compiler.

I think it was even documented somewhere, but I have been unable to tell what lines are added to the program exactly. And more importantly, why the editor adds code. Perhaps it has to do with the prompt that is shown after a program ends?

For debugging purposes it may be helpful to just let the TB compiler compile and run your code, from the Windows command-line:

From the Windows' Command Prompt, "CD" to the installation directory of TB.
Then run "TBSYSTEM path-to-your-TRU-file" (for example: "tbsystem TBDemos\ARROW.TRU"). A window will appear, asking what to do. Choose "Run" to run your program.

If your program consists of multiple source files, you should perhaps run the tbsystem program from within the root directory of your project. Let us know if you need more help.