Common scripting errors

ArmA editing, missions, modeling, textures, terrains

Moderators: Snake Man, Lone Wolf

Post Reply
Snake Man
Commander-In-Chief
Posts: 8556
Joined: 2000-07-31, 10:01:01 PM
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Common scripting errors

Post by Snake Man » 2009-05-10, 03:54:26 PM

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?
PMC since 1984

Editing knowledge, visit PMC Editing Wiki
Addon manuals, visit PMC addons/mods online manuals
View our videos in PMC Youtube channel.

PMC Tactical forum Advanced Search is power.

User avatar
Vigilante
Recruit
Posts: 33
Joined: 2008-12-03, 11:41:58 AM
Gaming Interests: Armed Assault (ArmA)
Editing Interests: All, I (try) to edit everything.
Contact:

Re: Common scripting errors

Post by Vigilante » 2009-05-10, 04:49:52 PM

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:
a.k.a. PhilippRauch
Check out my Addons Wiki @ http://vigilante-systems.webs.com (WIP but already contains lots of infos)

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04, 11:01:01 PM
Location: here

Re: Common scripting errors

Post by T_Rex » 2009-05-11, 03:55:21 AM

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. :)
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 8556
Joined: 2000-07-31, 10:01:01 PM
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Re: Common scripting errors

Post by Snake Man » 2009-05-11, 06:54:39 AM

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).
PMC since 1984

Editing knowledge, visit PMC Editing Wiki
Addon manuals, visit PMC addons/mods online manuals
View our videos in PMC Youtube channel.

PMC Tactical forum Advanced Search is power.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04, 11:01:01 PM
Location: here

Re: Common scripting errors

Post by T_Rex » 2009-05-11, 12:22:00 PM

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.
Sic Semper tyrannosauro.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests