Tutorial Details:
Difficulty Level:
Basic
Topics Covered: Including
comments using NQC and Mindscript.
Assumed Knowledge:
THe Basics
Written By: BILL LANE
BACK
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.
|