Jump to content
Sign in to follow this  
PartyHead

Spaces and Scripting ?

Recommended Posts

I probably should know this by now but here goes.

I've been learning scripting and mission making now since the start of Arma 2 although, I've bought every arma game since OFP. Anyway when I started learning how to script I first played a lot of popular missions to find out which scriptwriters to learn from, and to cut a long story short I learn t to script a particular way which automatically became my normal style and I've never really thought anymore about it.

What I'm referring to are spaces within script code. I've notice a lot of inconsistency between scriptwriters scripts in relation to spaces and I'm wondering what really is the best practice, if any, when it comes to spaces.

Do spaces have any performance impact on code ?

For example is it best to write code this way with spaces ?

[color="#FF0000"]eg.1[/color]
private ["_a", "_b", "_c", "_d"];

[color="#FF0000"]eg.2[/color]
for [{_i = 1}, {_i < (count _array0)}, {_i = _i + 1}] do {};

or this way without spaces ?

[color="#FF0000"]eg.1[/color]
private ["_a","_b","_c","_d"];

[color="#FF0000"]eg.2[/color]
for[{_i=1},{_i<(count _array0)},{_i=_i+1}]do{};

or doesn't it matter, is it just a case of personal preference ?

Sorry if this is a silly question or has been asked before, I couldn't find anything specifically about it.

Edited by PartyHead

Share this post


Link to post
Share on other sites

As a rule you should have spaces since the script may mistake elements as a variable name.

Also if you use notepad++ spaces between variables help with the colour coding.

Share this post


Link to post
Share on other sites

All tabs, spaces, linebreaks and comments are removed when the script is compiled, so no.

Filesize might increase by tiny amounts, nothing to worry about.

As for what is best - use whatever feels good and is easy to read.

Share this post


Link to post
Share on other sites
As a rule you should have spaces since the script may mistake elements as a variable name.

Also if you use notepad++ spaces between variables help with the colour coding.

Thanks for your reply BangaBob, I do use notepad++ mate and I've always used spaces like in my first examples.

All tabs, spaces, linebreaks and comments are removed when the script is compiled, so no.

Filesize might increase by tiny amounts, nothing to worry about.

As for what is best - use whatever feels good and is easy to read.

Thanks cuel for those answers, I didn't realize that about tabs, spaces, linebreaks and comments being removed when the script is compiled so i guess it doesn't really matter after all.

I'll keep doing what I've always done then.

Thanks.

Share this post


Link to post
Share on other sites

the "proper" way is to use spaces, at least in many other programming languages.

But in the end it does not matter and it is up to the programmer and what he thinks looks best.

Share this post


Link to post
Share on other sites

script your scripts like you want them to look like.

but do it consequently!

This is the same discussion like you want to buy a red or a green tshirt. It doesnt matter. some prefer this, others that.

like {

}

and

{

}

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  

×