rlm16
Oct 25th, 2007, 01:11 AM
I am using Liberty BASIC v4.03 on a PC with Windows XP.
I wrote a program using FOR/NEXT commands. The first time I use it is in a section for entering data. I have no trouble entering the data until I hit enter after the last number. Then I get an error message saying "Runtime Error: Subscript out of range: 11, xO."
Here is the code for that section:
[EnterData]
FOR i=0 to 11
PRINT
PRINT "Enter temperature for data point "; i+1; "."
INPUT Temperature(i)
PRINT
PRINT "Enter pressure for data point "; i+1; "."
INPUT Pressure(i)
NEXT i
PRINT
What am I doing wrong? Should I just go back to using:
IF i > 11, GOTO [Next]
GOTO [EnterData]
?
Thanks!
I wrote a program using FOR/NEXT commands. The first time I use it is in a section for entering data. I have no trouble entering the data until I hit enter after the last number. Then I get an error message saying "Runtime Error: Subscript out of range: 11, xO."
Here is the code for that section:
[EnterData]
FOR i=0 to 11
PRINT "Enter temperature for data point "; i+1; "."
INPUT Temperature(i)
PRINT "Enter pressure for data point "; i+1; "."
INPUT Pressure(i)
NEXT i
What am I doing wrong? Should I just go back to using:
IF i > 11, GOTO [Next]
GOTO [EnterData]
?
Thanks!