Program Flow
49 scripting commands. Also as Markdown for agents.
- a : bSee switch
- assertTests a condition and if the condition is false, displays error on screen (if -showscripterrors enabled) and logs error into .rpt file. It does not…
- breakSkips all loop iterations (for, forEach, while, findIf etc).
- breakOutBreaks out of the scope with given name. - An unknown scopeName name will cause the script error `Generic error in expression` - If multiple scopes…
- breakToBreaks block to scope named *name*.
- breakWithSkips all loop iterations and immediately returns the given value.
- callAdds given set of compiled instructions to the current stack and waits for it to finish and return, provides an option to pass arguments to the…
- canSuspendReturns true if sleep, uiSleep or waitUntil commands can be used in the current scope.
- caseThis command is used as a keyword inside a switch structure to define a value case.
- catchProcesses code when an exception is thrown in a try block. The exception caught can be found in the *_exception* variable.
- continueSkips current loop iteration and continues with the next one.
- continueWithSkips the current loop iteration, continues with the next one and returns the given value.
- defaultDefines a Switch Type default case - does not need a colon to define its block. See switch for more information.
- doExecutes *code*. Used as part of a construct, such as while, with, for and switch. The *code* is always executed in missionNamespace unless do is…
- elseExecutes else code when if condition returns false.
- execExecute a script using (the deprecated but still available) SQS Syntax. SQF Syntax (and execVM) is the most recent scripting language.
- execFSMExecute scripted FSM and return the FSM handle or 0 when failed. The FSM file is first searched in the mission folder, then in the campaign scripts…
- execVMCompiles and adds an SQF script to the scheduler queue and returns script handle (see also #Example 4).
- exitStops the execution of a SQS script.
- exitWithExits the current code scope. Often used for exiting do, for, count, forEach or the whole script.
- fileExistsChecks if file on given path exists. Uses same path resolve code as loadFile.
- forThis operator creates a For Type which is used in the for-constructs.
- forEachExecutes the given command(s) on every item of an Array or a HashMap.
- forEachMemberExecutes the given command recursively for both teams and agents that are members of the given team. For teams only use forEachMemberTeam. For agents…
- forEachMemberAgentExecutes the given command recursively for each agent that is a member of the given team. For just teams use forEachMemberTeam. For both teams and…
- forEachMemberTeamExecutes the given command recursively for each team that is a member of the given team. For just agents use forEachMemberAgent. For both teams and…
- forEachReversedExecutes the given command(s) on every item of an Array in reversed order, compared to forEach.
- fromContinue sequence of for construct. It sets the start value of the index variable.
- gotoBreak script flow and go to given label (defined by # - NOT to be confused with SQF's hash sign!)
- haltThis command was meant to break the script into debugger, however currently it does not do anything except displaying and logging the following…
- ifThis operator creates a If Type which is used in the if-construct as described here.
- isUIContextReturns true if the script originated from some UI control event, for example from "onButtonDown" EH. Exists within parent scope and immediate child…
- loadFileReturns the content of given files. If you plan to compile said string, be aware that the file should not contain comments or compile will throw an…
- scopeNameDefines name of current scope. Name is visible in debugger, and name is also used as reference in some commands like breakOut and breakTo. Scope name…
- scriptDoneCheck if a script is finished running using the Script Handle returned by execVM or spawn.
- scriptNameAssign a user friendly name to the VM script this command is executed from.
- sleepSuspends code execution for given time in seconds. The sleep precision is given by a framerate, the delay given is the minimal delay expected. Must…
- spawnAdds given set of compiled instructions to the scheduler. Exactly when the code will be executed is unknown, it depends on how busy is the engine and…
- stepOptional step value. A countdown can be made with a negative value. If not set, the default step is 1.
- switchChecks if the given parameter matches any case. If so, the code block of that case will be executed. After that the switch ends so no further cases…
- terminateTerminates (aborts) spawned or execVMed script.
- thenLinks an If Type with Code to be executed if said If Type's condition is true; otherwise, "else" code is executed if provided.
- throwThrows an exception. The exception is processed by first catch block. This command will terminate further execution of the code.
- toContinue sequence of for construct. It sets the end value of the index variable.
- tryDefines a try-catch structure. This sets up an exception handling block. Any thrown exception in a try block is caught in a catch block. The…
- uiSleepSuspend execution of script for given uiTime. uiSleep is a sleep method to delay script execution where script time/simulation time is stopped.
- waitUntilSuspends execution of scheduled script until the given condition satisfied.
- whileRepeats Code while the given condition is true. A part of while-do construct.
- withCreates a With Type that is used inside a do construct in order to execute code inside a given namespace.