comment: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|game([0-9]) ?= (.+) \|version([0-9]) ?= (.+) " to "|game$1= $2 |version$3= $4 ")
m (Some wiki formatting)
 
(18 intermediate revisions by 3 users not shown)
Line 24: Line 24:
|gr1= Strings
|gr1= Strings


|descr= Defines a comment. See {{HashLink|SQF Syntax#Comments}} to learn more about comments.
|descr= Defines a comment. See {{Link|SQF Syntax#Comments}} to learn more about comments.
{{Feature|Warning|This command is evaluated during execution, and as such is infinitely slower than other SQF comment methods (//comment or /*comment*/; which do not exist at runtime). See [[SQF Syntax|SQF Syntax]] for additional documentation on comments.}}
{{Feature|warning|
This command is evaluated during execution, and as such is infinitely slower than other SQF comment methods (<sqf inline>// comment</sqf> or <sqf inline>/* comment */</sqf>) which get preprocessed and do not exist at runtime).
See [[SQF Syntax|SQF Syntax]] for additional documentation on comments.
}}
{{Feature|informative|
This command is only used to place comments in unpreprocessed codes, such as trigger On Activation field, object init field, etc.
Alternatively, one can use a plain string followed by a semicolon as a way to comment; e.g <sqf inline>"Some comment";</sqf>.
}}


|s1= '''comment''' text
|s1= [[comment]] text


|p1= text: [[String]] - The comment
|p1= text: [[String]] - the comment


|r1= [[Nothing]]
|r1= [[Nothing]]
 
 
|x1= <code>[[comment]] "This is a commented line";</code>
|x1= In a preprocessed SQF script (e.g. when doing <sqf inline>execVM "myScript.sqf"</sqf>)
<sqf>
comment "This is a commented line"; // bad
"This is a commented line"; // slightly better
// This is a commented line // perfect
</sqf>
 
 
|x2= In an object init field (in editor):
<sqf>
comment "This comment works";
"This comment works too";
// This doesn't work
/* This doesn't work either */
</sqf>


|seealso= [[Control Structures]]
|seealso= [[Control Structures]]
}}
}}


<dl class="command_description">
{{Note
<dt><dt>
|user= Tom_48_97
<dd class="notedate">Posted on September 12, 2009 - 19:50</dd>
|timestamp= 20090912195000
<dt class="note">[[User:Tom_48_97|Tom_48_97]]<dd class="note">Like {{arma1}}, you can not use brackets to make a multi-lines comment. But, in a sqf file, you can make a comment as follow :
|text= Like {{arma1}}, you can not use brackets to make a multi-lines comment. But, in a sqf file, you can make a comment as follow :
<code>[[comment]] "
<sqf>
comment "
  first line
  first line
  seconde line";</code>
  seconde line";
</dl>
</sqf>
 
}}
<dl class="command_description">
<dt></dt>
<dd class="notedate">Posted on November 4, 2016 - 16:17 (UTC)</dd>
<dt class="note">[[User:Tofof|Tofof]]</dt>
<dd class="note">
If a file is loaded with [[preprocessFile]], [[execVM]] or [[spawn]] (but not [[loadFile]]), you may also define C-like comments using <tt>// ...</tt> and <tt>/*...*/</tt>.
</dd>
<dt><dt>
<dd class="notedate">Posted on November 4, 2016 - 20:46 (UTC)</dd>
<dt class="note">[[User:R3vo|R3vo]]</dt>
<dd class="note">
'''comment''' can also be used to create comments inside trigger activation fields where <tt>//</tt> or <tt>/*...*/</tt> don't work.
</dd>
</dl>

Latest revision as of 19:56, 7 April 2024

Hover & click on the images for description

Description

Description:
Defines a comment. See SQF Syntax - Comments to learn more about comments.
This command is evaluated during execution, and as such is infinitely slower than other SQF comment methods (// comment or /* comment */) which get preprocessed and do not exist at runtime). See SQF Syntax for additional documentation on comments.
This command is only used to place comments in unpreprocessed codes, such as trigger On Activation field, object init field, etc. Alternatively, one can use a plain string followed by a semicolon as a way to comment; e.g "Some comment";.
Groups:
Strings

Syntax

Syntax:
comment text
Parameters:
text: String - the comment
Return Value:
Nothing

Examples

Example 1:
In a preprocessed SQF script (e.g. when doing execVM "myScript.sqf")
comment "This is a commented line"; // bad "This is a commented line"; // slightly better // This is a commented line // perfect
Example 2:
In an object init field (in editor):
comment "This comment works"; "This comment works too"; // This doesn't work /* This doesn't work either */

Additional Information

See also:
Control Structures

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Tom_48_97 - c
Posted on Sep 12, 2009 - 19:50 (UTC)
Like Armed Assault, you can not use brackets to make a multi-lines comment. But, in a sqf file, you can make a comment as follow :
comment " first line seconde line";