SQS to SQF conversion: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
m (Fix examples)
 
(One intermediate revision by the same user not shown)
Line 22: Line 22:
|-
|-
| <sqs>; This is a comment</sqs>
| <sqs>; This is a comment</sqs>
<sqs>
<sqs notrim>
 
 
; This is a
; This is a
; multiline
; multiline
; comment
; comment
 
 
</sqs>
</sqs>
<sqs>comment "this is a comment";</sqs>
<sqs>comment "this is a comment";</sqs>
Line 77: Line 77:
|-
|-
|
|
<sqs>
<sqs notrim>
? CONDITION : goto "SKIP"
? CONDITION : goto "SKIP"
  COMMAND_2
  COMMAND_2
Line 85: Line 85:
  #END
  #END


 </sqs>
 
</sqs>
|
|
<sqf>
<sqf>
Line 125: Line 126:
? _i < COUNT : goto "LOOP"
? _i < COUNT : goto "LOOP"
</sqs>
</sqs>
| <sqf>
| <sqf notrim>
for "_i" from 0 to COUNT -1 do {
for "_i" from 0 to COUNT -1 do {
COMMAND;
COMMAND;
};
};


 </sqf>
 
</sqf>
|-
|-
! colspan="2" |
! colspan="2" |
Line 157: Line 159:
{ DEFAULT_COMMAND };
{ DEFAULT_COMMAND };
};
};
 </sqf>  
</sqf>  
|-
|-
! colspan="2" |
! colspan="2" |
Line 167: Line 169:
  COMMAND_1
  COMMAND_1
</sqs>
</sqs>
| <sqf>
| <sqf notrim>
if (CONDITION) exitWith { COMMAND_2; };
if (CONDITION) exitWith { COMMAND_2; };
COMMAND_1;
COMMAND_1;
 </sqf>
 
</sqf>
|}
|}



Latest revision as of 21:40, 21 July 2022

SQF Syntax has been introduced in Operation Flashpoint: Resistance v1.85 and is the Arma series' main scripting language since. The main differences with SQS Syntax are:

  • execVM is used (instead of exec for SQS)
  • Every command has to end with a semicolon (;)
  • the following commands disappeared:
  • Line returns do not impact code
  • SQF can return a variable, where SQS cannot


Conversion examples

SQS SQF

Comment

; This is a comment

; This is a ; multiline ; comment
comment "this is a comment";
"this is a comment";

// This is single-line comment
/* This is a multiline comment */
comment "this is a comment";
"this is a comment";

Condition wait

@CONDITION

waitUntil { CONDITION };

Delay

~DELAY
~5

sleep DELAY;

Conditional command

? CONDITION : COMMAND

if (CONDITION) then { COMMAND };

Multi-conditional command

? CONDITION : goto "SKIP" COMMAND_2 goto "END" #SKIP COMMAND_1 #END

if (CONDITION) then { COMMAND_1 } else { COMMAND_2 };

Cycle

#loop COMMAND ~DELAY ? CONDITION : goto "LOOP"

while { CONDITION } do { COMMAND; sleep DELAY; };

Cycle with step

_i = 0 #LOOP COMMAND _i = _i + 1; ? _i < COUNT : goto "LOOP"
for "_i" from 0 to COUNT -1 do { COMMAND; };

Structured conditional command

? VARIABLE == VALUE_1: goto "SKIP_1" ? VARIABLE == VALUE_2: goto "SKIP_2" DEFAULT_COMMAND goto "END" #SKIP_1 COMMAND_1 goto "END" #SKIP_2 COMMAND_2 #END
switch (VARIABLE) do { case VALUE_1: { COMMAND_1 }; case VALUE_2: { COMMAND_2 }; default { DEFAULT_COMMAND }; };

Exiting

? CONDITION : COMMAND_2 ? CONDITION : exit COMMAND_1
if (CONDITION) exitWith { COMMAND_2; }; COMMAND_1;


See Also