SQF Syntax: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
Line 23: Line 23:
While [[SQS syntax]] is line based, SQF syntax is based on structured expressions. End-of-line has no special meaning - it is considered to be equivalent to space or tab, and is therefore not required, even when ending a statement.
While [[SQS syntax]] is line based, SQF syntax is based on structured expressions. End-of-line has no special meaning - it is considered to be equivalent to space or tab, and is therefore not required, even when ending a statement.


==Language Constructs==
== Control Structures ==


Main language contructs used in functions are:
Read the article [[Control Structures]] for information about the control structures available in SQF syntax.
*[[if]]..[[then]]..[[else]]
 
*[[while]]..[[do]]
== Notes ==
* since [[ArmA]]: [[for]] ... [[from]] ... [[to]] ... [[step]]
* since [[ArmA]]: [[switch]] ... [[do]]
*Curled braces '''{ }'''
*Multiple commands (including assigment commands) are delimited with a semicolon.


==Notes==
Due to line-based nature of [[sqs syntax|Sqs scripts]] it is not possible to create multiline string constants in them.<br>
Due to line-based nature of [[sqs syntax|Sqs scripts]] it is not possible to create multiline string constants in them.<br>
To overcome this limitation you can store multiline in separate SQF [[Function|function]] files and load them using [[loadFile]] or [[preprocessFile]] (the second uses C-like preprocessor with // or /* */ comments and #define macros).<br>
To overcome this limitation you can store multiline in separate SQF [[Function|function]] files and load them using [[loadFile]] or [[preprocessFile]] (the second uses C-like preprocessor with // or /* */ comments and #define macros).<br>


==See also==
== See also ==
[[:Category:Scripting Commands|Commands]]
*[[call (ArmA)|call]]
*[[execVM]]
*[[spawn]]


[[Function]]
* [[SQS syntax]]
* [[Function]]


[[Category: Scripting_Topics]]
[[Category: Scripting_Topics]]

Revision as of 16:27, 21 December 2006

SQF syntax was introduced in Operation Flashpoint: Resistance and is the common syntax since Armed Assault. An alternative syntax is the SQS syntax (deprecated since Armed Assault).

Rules

Binding rules:

  • Curled braces ({ }) group code to blocks
  • Commands and blocks are followed by semicolons (;)

The latter rule tells the game engine where one command ends and the next starts.

Example:

Command 1;
Command 2;

Block
{
    Command 3;
    Command 4; 
};

While SQS syntax is line based, SQF syntax is based on structured expressions. End-of-line has no special meaning - it is considered to be equivalent to space or tab, and is therefore not required, even when ending a statement.

Control Structures

Read the article Control Structures for information about the control structures available in SQF syntax.

Notes

Due to line-based nature of Sqs scripts it is not possible to create multiline string constants in them.
To overcome this limitation you can store multiline in separate SQF function files and load them using loadFile or preprocessFile (the second uses C-like preprocessor with // or /* */ comments and #define macros).

See also