Statement: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(→‎Control Structure: Note for advanced readers)
m (Some wiki formatting)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
A '''statement''' is a piece of scripting code. It is an '''instruction''' to the [[Script Interpreter|script interpreter]] and tells it to do something.
__NOTOC__
A '''statement''' is a piece of scripting code. It is an '''instruction''' to the script Interpreter and tells it to do something.
 


== Types of Statements ==
== Types of Statements ==
A statement can be:
* [[Operators#Assignment Operators|value assignment]]
* [[Control Structures|control structure]]
* [[:Category:Scripting Commands|scripting command]]


=== Value Assignment ===
=== Value Assignment ===
Line 13: Line 9:
A [[Operators#Assignment Operators|value assignment]] to a [[Variables|variable]].
A [[Operators#Assignment Operators|value assignment]] to a [[Variables|variable]].


_variable = ...
<sqf>_variable = 5;</sqf>


=== Control Structure ===
=== Control Structure ===
Line 19: Line 15:
Any [[Control Structures|control structure]] including its blocks.
Any [[Control Structures|control structure]] including its blocks.


[[if]] (_value > _limit) [[then]]
<sqf>
{
if (_value > _limit) then
    [[hint]] "oh no";
{
}
hint "oh no";
 
};
''Note for advanced readers: in OFP/ArmA/VBS scripting language control structures are normal scripting commands. The distinction is only logical, not like in most imperative programming languages, where control statements are implemented in the core language grammar. The "controlling" done by them is implemented by accepting [[Code|code]] as an argument. The complex control structures like "[[while]] ... [[do]] ..." are implemented using helper types, like [[While Type]].''
</sqf>


=== Command ===
=== Command ===
Line 30: Line 26:
Any [[:Category:Scripting Commands|scripting command]] including its [[Argument|arguments]].
Any [[:Category:Scripting Commands|scripting command]] including its [[Argument|arguments]].


[[player]] [[sideChat]] "hello";
<sqf>player sideChat "hello";</sqf>
 


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

Latest revision as of 14:48, 22 July 2022

A statement is a piece of scripting code. It is an instruction to the script Interpreter and tells it to do something.


Types of Statements

Value Assignment

A value assignment to a variable.

_variable = 5;

Control Structure

Any control structure including its blocks.

if (_value > _limit) then { hint "oh no"; };

Command

Any scripting command including its arguments.

player sideChat "hello";