Jump to content
Sign in to follow this  
Taurus

Error missing { ?

Recommended Posts

Hello

Hmm

For some reason I looked at another view of this.

and my script-file was called blabla.sqs

switching to blabla.sqf and using

myFunc = compile loadFile "blabla.sqf"; ["param1","param2"] call myFunc;

and now the

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (condition) then

{

;something

};

Works smile_o.gif

Leaving this topic open for others to be helped with.

If moderators thinks otherwise. please remove

ORIGINAL TOPIC BELOW:

I'm currently having problems with my if else-statements.

Looking in the wiki it suggests:

if-Statement

The if-statement defines code that is only executed if a certain condition is met. The syntax of it looks like that:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (CONDITION) then

{

STATEMENT;

...

};

e.g.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (2 > 1) then

{

hint "omg!! it is larger than one!";

};

This returns "Error missing {

Same goes for

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (2 > 1) then

{

hint "omg!! it is larger than one!";

}

else

{

hint "Nah!! it's not!";

};

However

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (2 > 1) then {hint "omg!! it is larger than one!";};

Works.

BUT!

This is not a very good way of writing code as my if else-statements are bound to be rather big....

I want to have a greater over-view of things.

Any help would be gladly appreciated.

/e

Share this post


Link to post
Share on other sites

Yes in SQS put it into one line and it works. If you don't want to do that then just use SQF.

This "one line" style is very okay for relatively short statements, I've used them like that many times and it can even be better for readability to not spread a short statement to multiple lines, even if using SQF.

Share this post


Link to post
Share on other sites
Yes in SQS put it into one line and it works. If you don't want to do that then just use SQF

Thanks for your input.

SO what is more benefitial(word?)

.sqs or sqf

Part from the "one line" "more line" things?

.sqs = faster?

I would also like to know the difference between

spawn

execVM

and etc :S

I didn't understand the wiki's explanation about "holders".

Share this post


Link to post
Share on other sites

No, .sqs is definately not faster. In fact, .sqs is pretty much useless now, since .sqf is just far better.

Difference between execVM and spawn is that execVM compiles and executes an external .sqf file, where spawn executes a code block (similiar to call).

Share this post


Link to post
Share on other sites

I was under the impression that spawn executes preProcessed code at a "casual speed", while call runs in one frame. Correct?

I've been wondering about the benefit of preProccessing large scripts to be run slowly. As far as I can tell, preProcessing is basically just turning the file into a code block, removing comments etc. Does having HUGE global code blocks really help the games performance? I've always worked on the idea that less global variables = better.

Also, is there a limit. I seem to remember OFP had a maximum string length. Is there a maximum code block length?

Share this post


Link to post
Share on other sites
Quote[/b] ]Does having HUGE global code blocks really help the games performance?

Yes. In OFP when you executed a script, it was first loaded into memory, then processed to remove comments, create a list of goto labels, defined conditions and local variables e.t.c Each one of these processes takes time. Now say you have a script attached to a killed event and 10 units get killed. You are repeating the same process 10 times.

It all depends on what your doing. If you have a script that’s run once or twice per game then use ExecVM. But if you have a script that’s run 10, 20..100 times per game use spawn.

As far as variables go, Global variables should(?) only impact saved games. Other than that they should work exactly the same as local variables. In fact having lots of local variables might even be worse than having lots of global variables when it comes to memory management, if you assume in this case that global variables are also constants.

Global variables became notorious in OFP because of the limited space allocated to save game files. AFAIK nobody has confirmed if this is still the case in Arma?

Quote[/b] ]Also, is there a limit. I seem to remember OFP had a maximum string length. Is there a maximum code block length?

There was certainly a limit to how much text could be displayed on screen using certain commands. But I can't remember anyone every maxing out OFP with a large script. I'm sure there is a limit to script sizes, but has anyone every hit it?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×