Page 1 of 1

Common scripting errors

Posted: 2009-05-10 15:54:26
by Snake Man
Few basic scripting errors which are somewhat difficult to understand, at least for us newbies.

Code: Select all

Error in expression <-10>
  Error position: <-10>
  Error -: Type , expected Expression
I have absolutely no idea what this error is, difficult to find this "-10" and so on.

Does anyone have any idea what this error is?

Re: Common scripting errors

Posted: 2009-05-10 16:49:52
by Vigilante
how do you call the script? Via execVM?

I would rather call or spawn it with previous preProcess.. like so

Code: Select all

VIG_WP_new = compile preprocessFileLineNumbers "VIG_WP_new.sqf";
this way you get much better errormsg PLUS the line of code where it came from, well most of the time since it seems to ignore commentlines, so sometimes you have to deduct the previous commentslines from the linenr it puts out. I myself just started using that command instead of just preProcessFile ... ;)

And honestly, i never saw such errormsg like you posted before... and i had many of them :roll:

Re: Common scripting errors

Posted: 2009-05-11 03:55:21
by T_Rex
The "error: type, expected expression" to me means that you've given it a variable that it has no idea what it is. Maybe undefined, not in a "private"? Or, something you've assigned as nul/nil then tried to use? Maybe as part of a math command. I've never seen that particular error, though.

The most common error I do is to use a variable inside a loop, then expect that variable to have a value outside the loop. Commonly known as "scope" issues. :)

Re: Common scripting errors

Posted: 2009-05-11 06:54:39
by Snake Man
That error comes from our dedicated linux server when playing VTE missions. I see that error A LOT in there.

While we're talking about it, can you confirm how to use the preprocess thing, does it work like this:

Code: Select all

// set the script up
VIG_WP_new = compile preprocessFileLineNumbers "VIG_WP_new.sqf";
// run the script
VIG_WP_new;
And if I have a small script that is run once, do I have to make that VIG_WP_new thing if I understood correctly that its like the uhm compiled script "function" sort of?

What I mean is can I run small script used in a mission only once like:

Code: Select all

compile preprocessFileLineNumbers "VIG_WP_new.sqf";
And nothing more? (sorry I never done these before).

Re: Common scripting errors

Posted: 2009-05-11 12:22:00
by T_Rex
Close, but here's how I use it - this is from the OFPEC ComRef.
http://www.ofpec.com/COMREF/index.php?a ... ils&id=685

Code: Select all

// Pre-compile a function, with file name and line-number information stored within it.
myFunction = compile preprocessFileLineNumbers "myFunction.sqf";

// Call the function later.
_result = [_param1, _param2, _param3] call myFunction;
So, you compile the function into a "variable-name." Then the return value is held in the second variable.

If you aren't going to get a return variable, I think you still need the "call" command, or I believe you can use "spawn" for it to run sorta parallel.