Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Array out of bounds

Author
Message
Black Shadow
19
Years of Service
User Offline
Joined: 14th Oct 2004
Location:
Posted: 20th Apr 2005 08:58
Could some one please tell me why the heck this says the array is out of bounds and how to fix it?
wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 20th Apr 2005 12:21 Edited at: 20th Apr 2005 12:35
at the end of hexload it should be goto d
at the end of deciload it should be goto h

edit: or change the label names
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Apr 2005 23:44 Edited at: 20th Apr 2005 23:45
Which line is Out of Bounds?

I find FILE END easier to use...



BatVink
wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 21st Apr 2005 00:21
the reason it doesn't work is he is dim an array in one routine then going to another routine where the array hasn't been dimmed yet
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Apr 2005 01:27
You can Dim an array anywhere, so long as you Dim it before you use it.


I think this is the problem:



When J = the file size, you then continue to add 1, which breaks the limit of the array. It needs to be:



BatVink
wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 21st Apr 2005 05:50
Quote: "You can Dim an array anywhere, so long as you Dim it before you use it."

true, but he is going from one routine to another routine and trying to use an array that hasn't been dimensioned yet.
Quote: "
I think this is the problem:

+ Code Snippet
WHILE J<FILE SIZE(F$)
J=J+1
WRITE STRING 1,FILEH$(J)
ENDWHILE

When J = the file size, you then continue to add 1, which breaks the limit of the array. It needs to be:"

do you mean "<" is not working and it continues to add 1.

Quote: "
WHILE J<FILE SIZE(F$)
WRITE STRING 1,FILEH$(J)
J=J+1
ENDWHILE"

the test is at the beginning of the loop so this adds 1 more loop.

doesn't matter anyway. his code doesn't work and he isn't answering.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Apr 2005 07:37
Yes, I think I was talking rubbish about the WHILE loop

I wouldn't have written it like this, basing arrays on one variable, and loops on another. It's a typical trap that should be avoided.

BatVink

Login to post a reply

Server time is: 2024-09-23 17:30:27
Your offset time is: 2024-09-23 17:30:27