SQF Syntax: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 53: Line 53:


Read the article [[Control Structures]] for information about the control structures available in SQF syntax.
Read the article [[Control Structures]] for information about the control structures available in SQF syntax.
== Notes ==
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>


== See also ==
== See also ==

Revision as of 15:50, 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.

Comments

A comment is any free text which is ignored by the game engine. In SQF syntax you can write comments using the command comment.

Example:

comment "This is a comment";


If a file is loaded with preprocessFile, you may also define C-like comments:

Line comment
A line comment starts with // and makes the rest of the line a comment.
Block comment
A block comment starts with /* and ends with */. All text in between is considered a comment.

Examples:

// This is a line comment

/*
This is
a very long
block comment
*/

Language Constructs

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

See also