# Program Flow (scripting commands)

- [a : b](../../commands/a_~3A_b.md): See switch
- [assert](../../commands/assert.md): Tests a condition and if the condition is false, displays error on screen (if -showscripterrors enabled) and logs error into .rpt file. It does not interrupt the script execution.
- [break](../../commands/break.md): Skips all loop iterations (for, forEach, while, findIf etc).
- [breakOut](../../commands/breakOut.md): Breaks out of the scope with given name. - An unknown scopeName name will cause the script error `Generic error in expression` - If multiple scopes with the same name exist, the command will break out the nearest scope.
- [breakTo](../../commands/breakTo.md): Breaks block to scope named *name*.
- [breakWith](../../commands/breakWith.md): Skips all loop iterations and immediately returns the given value.
- [call](../../commands/call.md): Adds 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 executed Code.
- [canSuspend](../../commands/canSuspend.md): Returns true if sleep, uiSleep or waitUntil commands can be used in the current scope.
- [case](../../commands/case.md): This command is used as a keyword inside a switch structure to define a value case.
- [catch](../../commands/catch.md): Processes code when an exception is thrown in a try block. The exception caught can be found in the *_exception* variable.
- [continue](../../commands/continue.md): Skips current loop iteration and continues with the next one.
- [continueWith](../../commands/continueWith.md): Skips the current loop iteration, continues with the next one and returns the given value.
- [default](../../commands/default.md): Defines a Switch Type default case - does not need a colon to define its block. See switch for more information.
- [do](../../commands/do.md): Executes *code*. Used as part of a construct, such as while, with, for and switch. The *code* is always executed in missionNamespace unless do is used with with as an argument.
- [else](../../commands/else.md): Executes else code when if condition returns false.
- [exec](../../commands/exec.md): Execute a script using (the deprecated but still available) SQS Syntax. SQF Syntax (and execVM) is the most recent scripting language.
- [execFSM](../../commands/execFSM.md): Execute 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 folder and finally in the global scripts folder.
- [execVM](../../commands/execVM.md): Compiles and adds an SQF script to the scheduler queue and returns script handle (see also #Example 4).
- [exit](../../commands/exit.md): Stops the execution of a SQS script.
- [exitWith](../../commands/exitWith.md): Exits the current code scope. Often used for exiting do, for, count, forEach or the whole script.
- [fileExists](../../commands/fileExists.md): Checks if file on given path exists. Uses same path resolve code as loadFile.
- [for](../../commands/for.md): This operator creates a For Type which is used in the for-constructs.
- [forEach](../../commands/forEach.md): Executes the given command(s) on every item of an Array or a HashMap.
- [forEachMember](../../commands/forEachMember.md): Executes the given command recursively for both teams and agents that are members of the given team. For teams only use forEachMemberTeam. For agents only use forEachMemberAgent.
- [forEachMemberAgent](../../commands/forEachMemberAgent.md): Executes the given command recursively for each agent that is a member of the given team. For just teams use forEachMemberTeam. For both teams and agents use forEachMember.
- [forEachMemberTeam](../../commands/forEachMemberTeam.md): Executes the given command recursively for each team that is a member of the given team. For just agents use forEachMemberAgent. For both teams and agents use forEachMember.
- [forEachReversed](../../commands/forEachReversed.md): Executes the given command(s) on every item of an Array in reversed order, compared to forEach.
- [from](../../commands/from.md): Continue sequence of for construct. It sets the start value of the index variable.
- [goto](../../commands/goto.md): Break script flow and go to given label (defined by # - NOT to be confused with SQF's hash sign!)
- [halt](../../commands/halt.md) **[broken]**: This command was meant to break the script into debugger, however currently it does not do anything except displaying and logging the following error: `Error Debugger breakpoint hit`.
- [if](../../commands/if.md): This operator creates a If Type which is used in the if-construct as described here.
- [isUIContext](../../commands/isUIContext.md): Returns true if the script originated from some UI control event, for example from "onButtonDown" EH. Exists within parent scope and immediate child scopes.
- [loadFile](../../commands/loadFile.md): Returns 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 error.
- [scopeName](../../commands/scopeName.md): Defines 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 should be defined only once per scope.
- [scriptDone](../../commands/scriptDone.md): Check if a script is finished running using the Script Handle returned by execVM or spawn.
- [scriptName](../../commands/scriptName.md): Assign a user friendly name to the VM script this command is executed from.
- [sleep](../../commands/sleep.md): Suspends code execution for given time in seconds. The sleep precision is given by a framerate, the delay given is the minimal delay expected. Must be called inside of a context which is interruptible, i.e.
- [spawn](../../commands/spawn.md): Adds 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 how filled up is the scheduler.
- [step](../../commands/step.md): Optional step value. A countdown can be made with a negative value. If not set, the default step is 1.
- [switch](../../commands/switch.md): Checks 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 will be checked.
- [terminate](../../commands/terminate.md): Terminates (aborts) spawned or execVMed script.
- [then](../../commands/then.md): Links an If Type with Code to be executed if said If Type's condition is true; otherwise, "else" code is executed if provided.
- [throw](../../commands/throw.md): Throws an exception. The exception is processed by first catch block. This command will terminate further execution of the code.
- [to](../../commands/to.md): Continue sequence of for construct. It sets the end value of the index variable.
- [try](../../commands/try.md): Defines 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 structured exception block has the following form:
- [uiSleep](../../commands/uiSleep.md): Suspend execution of script for given uiTime. uiSleep is a sleep method to delay script execution where script time/simulation time is stopped.
- [waitUntil](../../commands/waitUntil.md): Suspends execution of scheduled script until the given condition satisfied.
- [while](../../commands/while.md): Repeats Code while the given condition is true. A part of while-do construct.
- [with](../../commands/with.md): Creates a With Type that is used inside a do construct in order to execute code inside a given namespace.
