Your computer would be just fine if you programmed it in assembler or machine code, but would you? BASIC is an easy to understand language with simple English keywords, but even BASIC programs can look cryptic and confusing without proper comments.
You can also use apostrophes to begin a comment. Unlike the keyword REM, you can place this second form of REMark after other BASIC statements.
Take a look at REMarks.bas to get an idea of how comments work. Run the code to see how QB ignores all REMarks.
' O------------------------O |
REMarks.bas |
The output for REMarks.bas should be:
This line gets printed.
These words are printed,
Note that you can place an apostrophe comment after the PRINT statement (or any other executable statement) but you can't place an executable statement after an apostrophe.
Different programmers use REMarks in different ways. You will see all of my programs start with a text box of sorts with each line beginning with an apostrophe. These text boxes contain information about the program. Similar, less ornate comments appear throughout my source code explaining what is happening in SUBs, FUNCTIONs, and wherever I feel the need.
You can use REMarks to explain what a SUB or FUNCTION is for, like this:
REM This function calculates collision damage.
When I first started looking at professional source code I noticed many inside jokes and general sillyness inside source comments, function names, and variable names. At first I thought it was annoying, and then I realized it helped programmers "play" with the variables, code, and functions. This kind of play increases a programmer's interest in the code and this in turn increases creativity and understanding of the code. So don't be surprised when you see references in other people's code to Monty Python, the Hitch Hiker's Guide, or game characters named superSpeedyBadass.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.