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.

Author
Message
Frank C
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 23rd Nov 2010 00:20
I'm trying to use arrays to hold data for randomly spawned enemies, however I am getting Runtime Error 118 - Array does not exist or array subscript out of bounds at line 1052 error when it actually generates the first random enemy, code snippets below:

From main program:



From Spawning include file


From Data reading include:


I'm pretty sure the problem is with RandomEnemies array but can't see where or why.
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 23rd Nov 2010 08:49
Where have you dimmed Entitytable()
also time for some debug code...
When you get the error what is the value of
spwn_index and enemyCnt?
Are they a valid number within range of your array elements?
Frank C
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 23rd Nov 2010 13:48
Quote: "Where have you dimmed Entitytable()"


Entitytable() is dimmed in the main program file, it is also filled at the beginning of the program during initialization.

I had some debug lines that I pulled out when I copied the code here but they would not show up when I ran the app.



I am looking at IanM's Matrix utilities to see how to use either the console or log ability to debug.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Nov 2010 14:13
The logging is fairly simple - there aren't very many commands.

Ignore the tags, as they're not mandatory, and there's not a lot left.

If you want to use OPEN LOG DEBUG, then download yourself a copy of the sysinternals debugview program and have that running while you run your program.

In addition, there's a simple way to determine whether your array has been defined at the point of use. You can grab the pointer to it, and if the value returned is zero, then you haven't executed the DIM for the array - that's necessary, as the DIM statement not only declared the array at compile-time, but allocates the storage for it at run-time.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Frank C
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 23rd Nov 2010 18:21
Thanks Ian I will look into it, I was able to implement the logging after some dll updating (kept getting mfc71 dll errors). The log file showed the following after the crash:

Enemy Index is: 0
spwn_index is: 0

I'm wondering why spwn_index is 0 since the following code is what generates the value:

curSpwnIndex = array count (RandomEnemies()) + 1
spawnEnemy(curSpwnIndex) <== function call curSpwnIndex is spwn_index

could empty array cause this, I call that after dimming the array to ensure it blank and at the beginning.
Frank C
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 23rd Nov 2010 18:32 Edited at: 23rd Nov 2010 18:58
I found the issue, the array count of RandomEnemies() is -1 while spwn_index is 0. I'm trying to figure out why it would be -1 or is that a result of using empty array? I will comment that out and try again.

[EDIT]: OK that was the problem, when I commented out the empty aray statements everything worked, but now I need to determine why I can't get it to generate any spawns.

Login to post a reply

Server time is: 2026-07-21 12:49:31
Your offset time is: 2026-07-21 12:49:31