Nesting
code, or creating a logic block, binds code together. A Block starts with a { and
end with a }. What this does is nest the code with the { and } meaning that the
code is only executed when the statement before it is active.
In this
example;
Blocks 2
& 3 are ignored unless Block 1 is active. So if the R2 button is not pressed,
nothing happens. If R2 is pressed, then the CronusMAX looks at Block 2. If
L2 is pressed, it will run the combo RAPID_FIRE_ADS and ignore Block 3. However,
if L2 is not pressed, it will ignore Block 2 and instead execute the code in Block 3 and
then run combo RAPID_FIRE.
Nesting
is implied if you only have one line of code after a statement. As in this
example;
When
compiled, the line combo_run(RAPID_FIRE); will automatically be
nested within the if statement.
If you wish for more than one line of code to only be executed when the statement before
them is active, then you must use { and }.
|
||
A
comment is text which is ignored by the compiler. Comments are usually used to
annotate code for future reference or to add notes for others looking at the code.
However, they can also be used to make certain lines of code inactive to aid when
debugging scripts. If you have programmed in C before then GPC comments will be
familiar to you as it uses the same style.
There
are two types of comments, the Single Line Comment and the Multi Line Comment.
Single Line CommentThe //
(two slashes) characters creates a single line comment and can be followed by any
sequence of character. A new line terminates this form of comment. As shown below
Multi Line CommentThe /*
(slash, asterisk) characters starts a multi line comment and can also be follow by any
sequence of characters. The multi line comment terminates when the first */
(asterisk, slash) is found. As shown below
As the
comment terminates when a */ (asterisk, slash) is found, this style of commenting cannot
be nested. As shown below
|
|||