|
-
Oct 25th, 2007, 01:11 AM
#1
Thread Starter
New Member
For/next
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!
-
Oct 25th, 2007, 01:23 AM
#2
Thread Starter
New Member
Re: For/next
I tried changing all of my FOR/NEXTs to IF/THEN GOTOs, but I got the same error message.
-
Oct 25th, 2007, 11:42 PM
#3
Hyperactive Member
Re: For/next
"Subscript out of range" is indicating your array isn't large enough to handle whatever is going into it.
Temperature(i), where "i" is out of bounds for your array size. Incease that by one or so in the declaration to resolve.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|