Scripting tutorial #8: Making Comments
What are comments and why are they important?
While cooking something have you ever felt like tweaking the recipe? If you did, and liked the result, how did you make a note of your change? Did you write it in the margins of the cookbook, or perhaps you stuck a little note on the page?
Programming has similar risks. It's surprisingly easy to forget how something you coded worked, and sometimes attempted "fixes" are just a waste of time. Thus, the ability to add comments directly into your code was invented. Just about every programming language has this feature, even markup languages like HTML and CSS have a way to include comments.
When noted properly, comments are completely ignored by whatever is reading the file they are in. This allows them to be written in proper English (or whatever human speak you prefer), and still be part of a file that's otherwise intended to be interpreted by the computer.
Comments are used for a number of things. They might explain how some code works, provide author and copyright information, or even turn off parts of the code. Using comments to disable code is known as "dummying out", and it's often used as a way to track down problems with a program. Once the problems have been solved, the comment markers are removed, allowing all of the code to run once again.
How to add comments in your scripts
The scripting language used by Mike's Sprite Editor borrows its commenting style wholesale from the language that inspired it - the humble MSDOS batch file. To start a comment, begin the line with the REM command. This command tells the editor to discard the entire line when the script is loaded.
Now that you know how to place comments in your code, there is only one more thing to learn before you're ready to fly solo. Head on to the next, and final, page of the tutorial to find out what this is.
On to the final tutorial page -->
<-- Back to the previous tutorial page