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 problems

Author
Message
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 19th May 2009 03:56 Edited at: 19th May 2009 03:59
Hello,
I declared an array like this:

then filtered through it assigning variables like this:

then assigned an object to that array like this:

and finally positioned it and tried to display its position:

but I get an array subscript error. Any suggestions? I can post the full source if you want.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 19th May 2009 04:11 Edited at: 19th May 2009 04:13
First of all...

Is "rocktotalspawnamt" greater than or equal to "rockgroup.type1.spwnamt"? If not then you will get an error since you are trying to put values into the array like this:



When the array only holds "rocktotalspawnamt" objects since you dimmed it like this:



^ Perhaps you meant to say "rockgroup.type1.spwnamt" here?


Second of all, on an unrelated note, I would be careful of the FIND FREE OBJECT() command. While it is rare that it will generate the same value twice, it is possible and you could get an OBJECT ALREADY EXISTS error when trying to make your rock objects. The reason why this can happen is because when you insert the free object number into each array slot, you never actually use that object number before the command is called again so it could be produced a second time and still count as a "free object".

Lastly, on which one of those lines of code does the subscript error appear?

<-- Spell based team dueling game!
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 19th May 2009 04:17 Edited at: 21st May 2009 03:38
@Sixty Squares:Yes, "rocktotalspawnamt" is greater than rockgroup.type1.spwnamt.

Thanks for the heads up about the find free object() function.

It occurs on the print line. "Runtime Error 128-Array does not exist or subscript is out of bounds"
-EDIT-I've solved it. It seems like my problem was that when I declared "rocks(rocktotalspawnamt)","rocktotalspawnamt" equaled 0.


Login to post a reply

Server time is: 2024-09-28 06:23:20
Your offset time is: 2024-09-28 06:23:20