Spybots Smart Parts  
  The Unofficial Resource Centre for Lego Spybotic  
   
img  
   
   

TUTORIALS

TUTORIALS

BASIC

making comments

Tutorial Details:
Difficulty Level: Basic
Topics Covered: Including comments using NQC and Mindscript.
Assumed Knowledge: THe Basics
Written By: BILL LANE

Print Version

Comments are things that we can write into a program that are ignored by the program. They allow us to leave messages inside the code for our own use or for anyone else who may need to look at our code.

For example, you might write a great long block of code to get your robot to perform some action. At the time of writing that code makes perfect sense. But six months later you need to make some changes but you can't remember what you did and why you did. If you comment your code then you should be aable to work it out quite quickly. The same is true if you want to share blocks of code with friends. So how do we add comments to our code? There are two formats for comments and these work exactly the same in Mindscript and NQC:

1. To make a comment on a single line simply place // where you want the comment to start. The comment runs from the two forward slashes until the end of the line.

Example:

   main()
   {
      
//this is a single line comment

      on [left]
// this single line comment starts after a command
   }

2. To make a comment run over multiple lines you can start the comment with /* and then finish it by using */.

Example:

   main()
   {
      
/* this comment extends over
      more than one line it will continue
      until it reaches the end of comment */

      on [left]

   }

As you can seeing including comments into your code is incredibly easy. So do your self a favour and put them to good use.

 

This tutorial is protected by International Intellectual Property Rights laws and may not be reproduced or redistributed in full or part, without the prior written consent of the author. Unauthorized reproduction of this tutorial or its contents may result in prosecution.

 

 
 
DISCLAIMER: All content is provided as is, with no warranty stated or implied regarding the quality or accuracy of any content on or off this site. All trademarks, service marks, and copyrights are property of their respective owners. This site is not sponsored, authorized or sanctioned by the LEGO Group nor representative of their opinions in any way.PRIVACY POLICY