Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subscript out of range
#1
Hello again. I am making my first RPG, so it's not all that great. But, my graphics are going to be using AWDRAW and .put files. Someone gave me this sub
Code:
DEFINT A-Z
L& = 0
FF = FREEFILE
OPEN Filename$ FOR BINARY AS #FF
L& = LOF(FF)
CLOSE #FF
Ints = (L& - 7) / 2
REDIM array(Ints) AS INTEGER
DEF SEG = VARSEG(array(0))
BLOAD Filename$, 0
DEF SEG

And it all worked out good but now for some reason it comes up with "Subscript out of Range" on REDIM array(Ints) AS INTEGER Can anyone help?!
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#2
1.-the indexes of the arrays are in QB in the range -16768 to 16767
if your file has more than 32k the index range will overflow, as you start from 0.Create an array of doubles instead. Or maybe fixed length strings...
2- Your array is static, so it shares the 64K of the DGroup with all your strings and other simple variables. Make your array '$Dynamic and be sure each element's size is a power of 2 (2, 4, 8, 16, 32, 64, 128..), then load QB with the /ah option.You will have more than 250 K for your array.

Another solution is to use a library saving graphics in EMS or XMS
Antoni
Reply
#3
Well, I don't know about all those file stuff or whatever, but I know that I do have '$DYNAMIC at the top of my program. I require to load QB with /l ... so how can i load /ah and /l ?
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#4
than 64 K (check your value of L&). Run QB with its /AH option (as was already pointed out):

QB /AH [/other options]

However, you're then going to have another problem. BLOAD won't work with more than 65,535 bytes (64 K -1 byte).
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)