SQF Syntax: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Fixed link)
(Fixed another link)
Line 10: Line 10:


With the release of Armed Assault, the SQS syntax for scripting was depreciated. SQF syntax is expected to be used for both scripts and [[Function|functions]].  
With the release of Armed Assault, the SQS syntax for scripting was depreciated. SQF syntax is expected to be used for both scripts and [[Function|functions]].  
[[SQS syntax]] is compiled line-by-line as it is executed. SQF files must be compiled ahead of time and are thus more efficient at time of execution. SQF scripts are compiled and executed with either the [[execVM]] command or manually via [[compile]] and [[spawn]]. Since scripts run parallel with each other, you must use [[scriptDone]] if you wish to have a ''calling'' script wait for a ''called'' script to finish.
[[sqs syntax|SQS syntax]] is compiled line-by-line as it is executed. SQF files must be compiled ahead of time and are thus more efficient at time of execution. SQF scripts are compiled and executed with either the [[execVM]] command or manually via [[compile]] and [[spawn]]. Since scripts run parallel with each other, you must use [[scriptDone]] if you wish to have a ''calling'' script wait for a ''called'' script to finish.
<br>
<br>



Revision as of 19:41, 20 December 2006

Introduction

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.

Operation Flashpoint

SQF syntax was introduced for the first time with the call command in Operation Flashpoint. Usage was limited to execution of functions.

Armed Assault

With the release of Armed Assault, the SQS syntax for scripting was depreciated. SQF syntax is expected to be used for both scripts and functions. SQS syntax is compiled line-by-line as it is executed. SQF files must be compiled ahead of time and are thus more efficient at time of execution. SQF scripts are compiled and executed with either the execVM command or manually via compile and spawn. Since scripts run parallel with each other, you must use scriptDone if you wish to have a calling script wait for a called script to finish.


Diagram of Scripts Running in Parallel

ParallelSQFScript.jpg


Diagram of Scripts Running in Parallel using waitUntil and scriptDone to pause execution

ParallelSQFScript WaitUntil.jpg


Language Constructs

Main language contructs used in functions are:

For Functions:
The result is the last expression evaluated (does not contain a final ';').
This can be Nothing when a function returns no value (contains a final ';').


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

Commands

Function