Index out of range and parse error
by DragonSix · in Torque Game Builder · 12/02/2007 (6:56 am) · 8 replies
"set::getobject index out of range"
"parse error"
These two error message are going to make me crazy, recently it happens often, but I just can't get to know where in the code it does happen (I have a ton of simset and eval going on).
Is the next patch is going to address the lack of information from these two error message ?
All I need is the file and the code line of where it happens. And I'm sure it could be pretty simple to pull off for someone who owns the source code. So why not making it stock ?
"parse error"
These two error message are going to make me crazy, recently it happens often, but I just can't get to know where in the code it does happen (I have a ton of simset and eval going on).
Is the next patch is going to address the lack of information from these two error message ?
All I need is the file and the code line of where it happens. And I'm sure it could be pretty simple to pull off for someone who owns the source code. So why not making it stock ?
#2
12/02/2007 (11:39 am)
If I get errors like that, which I cannot find, I throw echo's before each of the instances where there could be an error. Then, when the error pops up, you know which one is causing the issue.
#3
That one is pretty basic--you are calling getObject( ) on a SimSet (or SimGroup), with an index that is greater than the number of objects in the set. If you only have, for example, 3 objects in a set, then you can't get the 5th object.
Since this is a run time error, not a parse error, their is no clean way to report where the TorqueScript that caused the error resides without keeping track of quite a bit more information about your TorqueScript files within the executable. At this point, the engine is only dealing with byte code compiled versions of your script files.
Keeping track of that type of information is more normally associated with an IDE, such as Torsion.
This means you are most probably using an eval statement, and the code the eval is generating is not proper TorqueScript syntax. Inspect the value of anything you eval prior to actually evalling it is always good practice.
Or you can use Torsion, which will allow you to pre-compile scripts, report any errors, and in 95% of the cases double click on the error report line and it opens the file and goes to the line that the error exists.
12/02/2007 (1:53 pm)
Quote:
"set::getobject index out of range"
That one is pretty basic--you are calling getObject( ) on a SimSet (or SimGroup), with an index that is greater than the number of objects in the set. If you only have, for example, 3 objects in a set, then you can't get the 5th object.
Since this is a run time error, not a parse error, their is no clean way to report where the TorqueScript that caused the error resides without keeping track of quite a bit more information about your TorqueScript files within the executable. At this point, the engine is only dealing with byte code compiled versions of your script files.
Keeping track of that type of information is more normally associated with an IDE, such as Torsion.
Quote:
"parse error"
This means you are most probably using an eval statement, and the code the eval is generating is not proper TorqueScript syntax. Inspect the value of anything you eval prior to actually evalling it is always good practice.
Quote:
If I get errors like that, which I cannot find, I throw echo's before each of the instances where there could be an error. Then, when the error pops up, you know which one is causing the issue.
Or you can use Torsion, which will allow you to pre-compile scripts, report any errors, and in 95% of the cases double click on the error report line and it opens the file and goes to the line that the error exists.
#4
If you want to find where it's occurring you'll have to follow it down with a debugger. I think it may require going down to the source level. You can find that error message by doing a text search for it then putting a breakpoint at the actual source line. Gets pretty confusing to figure out what's going on in the engine though. At least for me.
12/02/2007 (8:22 pm)
I agree with Stephen about the reason that these errors occur. However, I think that they are caused by something in the TGB code, because I have verified that they still occur when I am not doing anything in my scripts that could cause them. I haven't actually hunted them down yet, but I definitely see them too.If you want to find where it's occurring you'll have to follow it down with a debugger. I think it may require going down to the source level. You can find that error message by doing a text search for it then putting a breakpoint at the actual source line. Gets pretty confusing to figure out what's going on in the engine though. At least for me.
#5
Because the only case where I call "getobject" is only in the following way :
It seems like the getcount return false informations sometimes O_o
12/02/2007 (9:46 pm)
Quote:I think that they are caused by something in the TGB code, because I have verified that they still occur when I am not doing anything in my scripts that could cause them. I haven't actually hunted them down yet, but I definitely see them too.Yep, this is what's happening to me, the simset manipulation are fine, but sometimes I get this error for no logical reason. Like if it doesn't now that I removed some objects from the simset or deleted the objects.
Because the only case where I call "getobject" is only in the following way :
%count = simset.getcount();
for ( %i = 0; %i < %count; %i++ )
{
%object = simset.getobject(%i);
//then whatever code I want to do on the object
}So, logically, it would be impossible to get the out of range error. It seems like the getcount return false informations sometimes O_o
#6
For the record, I'm not stating that it must be your code--it very well could be built in stuff that's causing the warnings.
12/03/2007 (9:17 am)
Actually, it's not impossible at all to get the out of range error, if you do something within your loop that could possibly remove members from the set. In fact, it's a common error we see :)For the record, I'm not stating that it must be your code--it very well could be built in stuff that's causing the warnings.
#7
12/03/2007 (9:30 am)
As a test, try making your loop only "simset.getobject(%i);" ?
#8
Thanks a lot Stephen. It was indeed my code ^^'
12/03/2007 (11:11 pm)
Quote:if you do something within your loop that could possibly remove members from the set.Ah! You got me, your guess is right on the spot! I didn't thought at all about that and did this mistake in several places, shame on me :O
Thanks a lot Stephen. It was indeed my code ^^'
Torque Owner Skylar Kelty
SkylarK