SQS Syntax: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<tt>([^= ]+)<\/tt>" to "{{hl|$1}}")
m (Some wiki formatting)
Line 1: Line 1:
{{TOC|side|1|}}
{{TOC|side|1|}}
[[SQS Syntax]] (where SQS stands for Status Quo Script) was the main [[Syntax|syntax]] in [[:Category:Operation Flashpoint|{{ofp}}]] and is still available in {{GameCategory|arma1|link=y}}. It can only be used for [[Script File|scripts]], but not for [[Function|functions]], in the [[ArmA: Mission Editor|Mission Editor]] or in addon config files. The alternative syntax is [[SQF Syntax]].
[[SQS Syntax]] (where SQS stands for Status Quo Script) was the main [[Syntax|syntax]] in [[:Category:Operation Flashpoint|{{ofp}}]] and is still available in {{GameCategory|arma1|link=y}}. It can only be used for [[Script File|scripts]], but not for [[Function|functions]], in the [[ArmA: Mission Editor|Mission Editor]] or in addon config files. The alternative syntax is [[SQF Syntax]].


== Rules ==
== Rules ==
Binding rules:
Binding rules:


Line 9: Line 11:


=== Example ===
=== Example ===
  STATEMENT 1
  STATEMENT 1
  STATEMENT 2; STATEMENT 3, STATEMENT 4
  STATEMENT 2; STATEMENT 3, STATEMENT 4
   
   
  BLOCK { STATEMENT 5; STATEMENT 6 }
  BLOCK { STATEMENT 5; STATEMENT 6 }


== Comments ==
== Comments ==
A line beginning with a '''semicolon''' (;) is considered a comment and ignored by the game engine.
A line beginning with a '''semicolon''' (;) is considered a comment and ignored by the game engine.


=== Example ===
=== Example ===
; this is my comment
 
<sqs>; this is my comment</sqs>
 


== Language Constructs ==
== Language Constructs ==
The control structures listed in the article [[Control Structures]] may also be used in SQS syntax. Note that they must be written '''within a single line''' due to the above rules.
The control structures listed in the article [[Control Structures]] may also be used in SQS syntax. Note that they must be written '''within a single line''' due to the above rules.


=== Example ===
=== Example ===
[[if]] (_value==1) [[then]] {[[hint]] "Value is 1"} [[else]] {[[hint]] "Value is not 1"}
 
<sqs>if (_value==1) then {hint "Value is 1"} else {hint "Value is not 1"}</sqs>


There exist also special structures limited to SQS syntax.
There exist also special structures limited to SQS syntax.


=== Label ===
=== Label ===
You may define labels in the code by beginning a line with {{hl|#}}, followed by the name of the label (without spaces). You may use the command [[goto]] at any point of the [[Script File|script]] to jump to this label.
You may define labels in the code by beginning a line with {{hl|#}}, followed by the name of the label (without spaces). You may use the command [[goto]] at any point of the [[Script File|script]] to jump to this label.


#Label1
<sqs>
#Label1
CODE
 
hint "repeating"
[[goto]] "Label1"
 
goto "Label1"
</sqs>


=== Conditional ===
=== Conditional ===
You may query a [[Boolean]] condition and define code, that is executed ''only'' when the condition is {{hl|true}}. Note that there is no equivalent for "else". A conditional line must start with {{hl|?}}, followed by the condition and {{hl|:}}, followed by one or more commands. Multiple commands  are separated by commas (,) or semicolons (;). The conditional statement ends with the end of the line.
You may query a [[Boolean]] condition and define code, that is executed ''only'' when the condition is {{hl|true}}. Note that there is no equivalent for "else". A conditional line must start with {{hl|?}}, followed by the condition and {{hl|:}}, followed by one or more commands. Multiple commands  are separated by commas (,) or semicolons (;). The conditional statement ends with the end of the line.


? CONDITION : STATEMENT 1; STATEMENT 2
<sqs>? alive target : hint "target is alive, let's destroy it"; target setDammage 1</sqs>


=== @ ===
=== @ ===
Much like the [[waitUntil]] statement in [[SQF Syntax]], @ will evaluate a certain condition, and the script will pause until @ returns [[true]].
Much like the [[waitUntil]] statement in [[SQF Syntax]], @ will evaluate a certain condition, and the script will pause until @ returns [[true]].


@ CONDITION
<sqs>@not alive target</sqs>
 


== Notes ==
== Notes ==
Due to line-based nature of [[SQS Syntax|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|function]] files and load them using [[loadFile]] or [[preprocessFile]] (the second uses C-like preprocessor with // or /* */ comments and #define macros).
 
Due to line-based nature of [[SQS Syntax|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|function]] files and load them using [[loadFile]] or [[preprocessFile]] (the second uses C-like preprocessor with // or /* */ comments and #define macros).
 


== Limitations ==
== Limitations ==
In '''{{ofp}} v1.96''', if a single line of a sqs file is longer than 4096 characters, {{ofp}} will return an error and will not execute the line.
In '''{{ofp}} v1.96''', if a single line of a sqs file is longer than 4096 characters, {{ofp}} will return an error and will not execute the line.


== See also ==
== See also ==
* [[SQF Syntax]]
* [[SQF Syntax]]
* [[Script File]]
* [[Script File]]
* [[Statement]]
* [[Statement]]
* [[Block]]
* [[Block]]


[[Category: Syntax]]
[[Category: Syntax]]

Revision as of 15:46, 1 July 2022

SQS Syntax (where SQS stands for Status Quo Script) was the main syntax in Operation Flashpoint and is still available in ArmA: Armed Assault. It can only be used for scripts, but not for functions, in the Mission Editor or in addon config files. The alternative syntax is SQF Syntax.


Rules

Binding rules:

  • Statements are separated by line breaks and semicolons (;) and commas (,). This means that a statement must not span over multiple lines.
  • Curled braces ({ }) group code to blocks. A block is considered a single statement, thus may not span over multiple lines.

Example

STATEMENT 1
STATEMENT 2; STATEMENT 3, STATEMENT 4

BLOCK { STATEMENT 5; STATEMENT 6 }


Comments

A line beginning with a semicolon (;) is considered a comment and ignored by the game engine.

Example

; this is my comment


Language Constructs

The control structures listed in the article Control Structures may also be used in SQS syntax. Note that they must be written within a single line due to the above rules.

Example

if (_value==1) then {hint "Value is 1"} else {hint "Value is not 1"}

There exist also special structures limited to SQS syntax.

Label

You may define labels in the code by beginning a line with #, followed by the name of the label (without spaces). You may use the command goto at any point of the script to jump to this label.

#Label1 hint "repeating" goto "Label1"

Conditional

You may query a Boolean condition and define code, that is executed only when the condition is true. Note that there is no equivalent for "else". A conditional line must start with ?, followed by the condition and :, followed by one or more commands. Multiple commands are separated by commas (,) or semicolons (;). The conditional statement ends with the end of the line.

? alive target : hint "target is alive, let's destroy it"; target setDammage 1

@

Much like the waitUntil statement in SQF Syntax, @ will evaluate a certain condition, and the script will pause until @ returns true.

@not alive target


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).


Limitations

In Operation Flashpoint v1.96, if a single line of a sqs file is longer than 4096 characters, Operation Flashpoint will return an error and will not execute the line.


See also