Difference between revisions of "SQS to SQF conversion"

From Bohemia Interactive Community
Jump to navigation Jump to search
(Article about difference between SQS and SQF. I'm not sure with headings (Command with condition, ...), so feel free to correct it.)
 
m (Structured command with condition)
Line 49: Line 49:
 
  #SKIP
 
  #SKIP
 
  COMMAND_1
 
  COMMAND_1
  "END"
+
  #END
 
}}
 
}}
 
{{Box_File|SQF|color_dark=#78AF78|color_light=#f2fff2|
 
{{Box_File|SQF|color_dark=#78AF78|color_light=#f2fff2|

Revision as of 17:26, 1 March 2007

What's different in SQF

  • Every command have to be ended with semicolon.
  • Cycles are limited to 10 000 loops.

Replacing

Comment

SQS
; This is a comment
SQF
// This is single-line comment
/* This is multiline
   comment
*/
comment "And this is comment working both in SQS and SQF";


Condition

SQS
@CONDITION
SQF
waitUntil {CONDITION};


Delay

SQS
~DELAY
SQF
sleep DELAY;


Command with condition

SQS
?CONDITION: COMMAND
SQF
if (CONDITION) then {COMMAND};


Structured command with condition

SQS
?CONDITION: goto "SKIP"
COMMAND_2
goto "END"
#SKIP
COMMAND_1
#END
SQF
if (CONDITION) then {COMMAND_1} else {COMMAND_2};


Cycle

SQS
#loop
COMMAND
~DELAY
?CONDITION: goto "LOOP"
SQF
while {CONDITION} do {
 COMMAND;
 sleep DELAY;
};


Cycle with step

SQS
_n = 0
#LOOP
COMMAND
_n = _n + 1;
?_n < COUNT: goto "LOOP"
SQF
for [{_n = 0},{_n <= COUNT},{_n = _n+1}] do {
 COMMAND;
};


Structured command with conditions

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