July 14, 2003, 12:00 AM — Last week, we showed you how to retrieve arguments from the command
line. This week we examine commenting code.
It is important to comment your code, not only for your benefit but also
for others that you share your code with. If you have not noticed, most
of the sample programs I have developed for you have not had many
comments. The reasons I did not comment the code was because of space
considerations and since I was already explaining the code in question.
However, you may not be around to show the next person that uses your
code why you did something, or what a particular code segment within
your program is supposed to do.
Commenting your code is very easy and can be accomplished by simply
putting an apostrophe ' in front of any line of code within your
program.
For example, the following line is NOT commented:
For i = 0 to (WScript.Arguments.Count - 1)
However, the next line IS commented:
'For i = 0 to (WScript.Arguments.Count - 1)
The only difference is the apostrophe at the beginning of the line. The
apostrophe can occur anywhere within your line of code, for example:
For i = 0 to (WScript.Arguments.Count - 1) 'Beginning of my For...Next
Loop
In the above example, we placed our comment after our line of code. It
is usually based upon preference whether or not you place your comment
at the beginning of the line or after a line of code.
When I write functions or procedures, I will usually preface the code
with a description of the function, and what kind of input (if any) that
the function expects. This makes it easy for me to re-use my code in
other programs.
See you next week when we begin a discussion on functions and procedures
within VBScript.


















