Difference between revisions of "Comments"

From Kolmafia
Jump to navigation Jump to search
imported>Zarqon
(created page)
 
imported>StDoodle
m
Line 4: Line 4:
  
 
ASH has three different options for commenting -- the pound sign (#), the double forward slash (//), and the block comment (everything between /* and */).  See the following example:
 
ASH has three different options for commenting -- the pound sign (#), the double forward slash (//), and the block comment (everything between /* and */).  See the following example:
 
+
{{CodeSample|
<code>
+
code=
  # this entire line is commented
+
<syntaxhighlight>
  // so is this entire line
+
# this entire line is commented
 +
// so is this entire line
 
    
 
    
  /*
+
/*
    This is part of a block comment.
+
  This is part of a block comment.
    That means that all of this is commented.
+
  That means that all of this is commented.
    Commands within comments are not executed.
+
  Commands within comments are not executed.
    print("This will not be printed.");
+
  print("This will not be printed.");
    Note that the opening and closing symbols for block comments must be on their own lines!
+
  Note that the opening and closing symbols for block comments must be on their own lines!
  */
+
*/
 
    
 
    
  print("This will be printed.");  // Single-line comments can be on the same line as commands.
+
print("This will be printed.");  // Single-line comments can be on the same line as commands.
 
    
 
    
  this line will generate an error since it is not commented
+
this line will generate an error since it is not commented
</code>
+
</syntaxhighlight>}}
 +
 
 +
 
  
 
As far as KoLmafia is concerned when running the script, that entire example looks like this:
 
As far as KoLmafia is concerned when running the script, that entire example looks like this:
  
<code>
+
{{CodeSample|
  print("This will be printed.");
+
code=
 +
<syntaxhighlight>
 +
print("This will be printed.");
 
    
 
    
  this line will generate an error since it is not commented
+
this line will generate an error since it is not commented
</code>
+
</syntaxhighlight>}}

Revision as of 09:09, 13 April 2010

A comment is non-functional text in a script, which is ignored by KoLmafia when running the script. They are most commonly included to help someone reading/editing the script (including the script author!) to understand or navigate the script. Sometimes commands are "commented out" during debugging, to prevent them from being executed while testing.

It is generally considered good practice when writing a script to include a few comments explaining the purpose of various sections, especially to clarify any difficult-to-understand parts.

ASH has three different options for commenting -- the pound sign (#), the double forward slash (//), and the block comment (everything between /* and */). See the following example:

# this entire line is commented
// so is this entire line
  
/*
  This is part of a block comment.
  That means that all of this is commented.
  Commands within comments are not executed.
  print("This will not be printed.");
  Note that the opening and closing symbols for block comments must be on their own lines!
*/
  
print("This will be printed.");   // Single-line comments can be on the same line as commands.
  
this line will generate an error since it is not commented



As far as KoLmafia is concerned when running the script, that entire example looks like this:


print("This will be printed.");
  
this line will generate an error since it is not commented