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 subscript problem or array out of place. please help.

Author
Message
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 09:55
i have used the multi bullet code created by bishop and put it into my code. i have simple ai for a cube that runs towardsme and at a certain distance he will start shooting. i tried to take bishops code and put in different vriables and i think i have it all down.
but it says i have an array subscript problem or the array is out of bounds.
i have included the complete code so if you have the time plz read through and see if you no what is happening.i am haveing trouble with the totammo# variable and collision but you dont have to look at those if you dont want to.
any other tips,hints would be appreciated too,thx!

mulletman47@aol.com
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jul 2004 10:48
You have this on line 103:

dim eneactive(300,2)

Then you have this on line 314:

eneactive(e,201)=200

201 is a little bit more than the 2 you used to create the array in the first place. That's why you are getting subscript out of range errors. You'll get the same on the following line too.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 12:51
should i turn the 2 into a 201 or the 201 into 2?

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 13:32
Ah.. I see..
in those two lines, the code says;

eneactive(e,201)=200
eneactive(e,202)=300

When the values clearly should be;

eneactive(e,1)=200
eneactive(e,2)=300

for a starting location.

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 13:45
im still getting the same error

mulletman47@aol.com
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 13:49
scratch that last transmission the error is at this line now


for e=201 to 300

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 13:54
Hmm...

Well? just for the fun of it, put an END after loop to see if the code is "falling through" to the subroutines and trying to access an E that's not set.

Next, change your dim statement to dim eneactive(301,3) or something to see if it a out of subscript error.

And finally, put a PRINT E command into the loop and see what E really is, or a BREAK command and ask the command line to print the value of E.

Simple, easy debugging processes...

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 13:55
kk

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 14:02 Edited at: 3rd Jul 2004 14:03
Okay, I've looked at the code farther now and see that you have functions "inside" the main code, by that I mean, the enemyshoot subroutine is below the functions you have called. I'm not sure if this style is allowed in Dark Basic, because most folks put their functions down at the end, so I'd suggest trying to move enemyshoot "up" below the loop and before the first function defined.

S.

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 14:03
ok i changed the for e=201 to 300

to for e=200 to 300

just to check and i got a different error.
it said object does not exist here

position object e,object position x(104),object position y(104),object position z(104)



which is the first line dealing with e after the for line. which makes me think that there was another error screwing it up. im thinking somehow it doesnt know the "e"s are being created.

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 14:05
Yes, if you change the for e=201 to 300 line you will get an Object does not exist error, because you've only made objects 201 to 300 for the bullets.

That's why you change the array size, not the code that asks to access it.

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 14:07
ok i moved enemy shoot

loop
end
gosub enemyshoot

and the print e command is saying on the screen e is 301. isnt that out of what we said? like 201 to 300 and 200 to 300

mulletman47@aol.com
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 14:15
gosub enemyshoot
Radar()

sync

loop

i tried here too

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 18:43
Yup, if e = 301 then it IS beyond the range of the array just as DB complains it is, since the original array was only 0-300. There is an error somewhere that is setting E to "too far" beyond the object values, so you can avoid that by a simple check;
if e < 301
(rest of detect/move code)
endif

Though why it would ever be 301 I have NO FREAKING IDEA! This defies logic... the for loop defines the value and while or how it could ever be beyond those limits is way over my head. This makes no sense to me... maybe I better look at the code again.
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 05:11
Hi again...

I've grabbed a copy of your code and pasted it my word processor to reorganize and peruse it some more, and it occurs to me that you might want to make sure that the 1's you have in the changed sections really are 1's and not lower case L. (Those two can really mess you up.)

I still do not understand why E would be 301 however, so why not try changing E to like P for that section and see if it still does it. If it does, we may have found a bug in the FOR-NEXT loop, for which I'd suggest changing the FOR E=201 to 300 to FOR E=201 to 299 and see if that makes the error go away. As I have DBC I can't run the code to see what my DB says of it, because it would be so changed by that time conditions would be different.

Goos luck!
S.

(See other thread too.)

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 5th Jul 2004 09:34
Man, Ive tried eveything you told me and everthing i could think of! I stil get th same error. Im thinking of taking the code out and redoing it or making a seperate game just for the ai and enemy shooting. Maybe someone with pro can compile it and see what they think. Thx SandraD so much for you support if you think of anything post it and i'll try it.
Over and out.

mulletman47@aol.com

Login to post a reply

Server time is: 2024-09-22 15:35:37
Your offset time is: 2024-09-22 15:35:37