Comments are not important to LiveCode, because they will always be ignored. But Comments are very important to those programmers who maintain the code. If the comments are written well, it gives a lot of information about what the program is doing and why. This is invaluable information if you are only somewhat familiar with each section.
- Programmer 1 creates a new program and maintains it for a couple of years. Since he wrote the program and understands it inside and out, he doesn't worry about putting in comments. Then he leaves.
- Programmer 2 is tasked with maintaining that program. He only has a vague idea how the program works and doesn't find any comments to help him along. As a result, he spends all day going over that program, for weeks at a time putting in comments as he began to understand the program. Then he leaves
- Then Programmer 3 is tasked with maintaining that program. He only has a vague idea how the program works, but because of the good comments he quickly gets a good understanding. After a week, he can turn his attention to other things. Then when changes need to be made, he could quickly make the changes because he understood what the program was doing.
Since LiveCode ignores comments, you can use them for debugging. If you don't want a particular line of code to execute right now, then make it into a single line comment. Temporarily put one of the single line comment identifiers before that line. Later you can remove the comment identifiers and LiveCode will resume executing that line.
A comment can be on its own line(s), or after any other LiveCode statement. The next four examples are various ways to make comments in LiveCode:
A multi-line example:
/* This is an example of a multi-line comment. It starts with a forward slash and star and continues over several lines. It ends with a star and forward slash. */
Single-line examples using a hash mark (#):
# Hello, I'm a comment put 5 into myVar # Hello, I'm a comment too.
Single-line examples using two dashes (--):
-- Hello, I'm a comment put 16 into myNum -- Hello, I'm a comment too.
Single-line examples using two forward slashes (//):
// I am a comment put 65 after myConst // I am a comment also