Script errors not found
by Mark R Rivet · in General Discussion · 07/27/2009 (9:17 am) · 3 replies
Hello all this is my first post to the forums.I have just purchased the 3d all in on game programming book and I am going through it now. I entered in the very simple while loop example program and the first time it hung up my system, but it was because of type O.
function runWhilingAway()
{
%value = 0;
while (%value < 7)
{
%valui = GetRandom(10);// miss spelled %value made the program crash
echo("value=" @ %value);
}
}
The miss spelling of the variable did not come up in the torque compiler as an error. Is this something I will have to live with? I thought maybe because I had used the %value variable above, it may have picked up the miss spell; but the %value above is not actually a variable declaration, or is it? Can you point out what I did wrong, or is that the way it just is. I know that compilers will pick up syntax errors and usually not logical errors.
function runWhilingAway()
{
%value = 0;
while (%value < 7)
{
%valui = GetRandom(10);// miss spelled %value made the program crash
echo("value=" @ %value);
}
}
The miss spelling of the variable did not come up in the torque compiler as an error. Is this something I will have to live with? I thought maybe because I had used the %value variable above, it may have picked up the miss spell; but the %value above is not actually a variable declaration, or is it? Can you point out what I did wrong, or is that the way it just is. I know that compilers will pick up syntax errors and usually not logical errors.
#2
07/27/2009 (9:36 pm)
It seems I'm mistaken. After poking through the code, I happened to come across the variable $Con::warnUndefinedVariables (at least in TGB, anyway). Set it to true and it will output warnings to the console if you read from a variable that has not yet been assigned. It would still not catch your typo as above, however, because your typo was in the variable assignment rather than in the variable access.
#3
07/28/2009 (3:32 pm)
Yes, you are right, it does not seem that there is a way to pick up unintended variable type o's because the declaration is made at the same time. I wonder however, if I make the declaration as %variable, and the use the variable name without the % sign if that would work.
Torque Owner Greg Beauchesne