Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
If you have ever written a lengthy report or memorandum, you might have found it useful to type notes to yourself as you worked on the document. For example, you might have typed something such as, "Need to add a section here about the budget problems from a year ago" or "These two paragraphs need to be rewritten." Notes such as these are useful reminders and also serve as a sort of status report, letting you know what is and is not working, and how you are progressing.
Comments allow you to put this same type of status report in scripts still in development. For example, suppose you are working on a script and you encounter a problem. If you are unable to immediately solve the problem, insert a comment labeled BUG to indicate that this section of code needs further work. The next time you work on that script, search for BUG to locate any sections of the code that are not working properly. If you are able to fix the problem, remove the BUG comment.
For example, you might use the following comment labels:
The following script snippet illustrates comments used as a debugging aid.
'* BUG (DMS 3/10/02) This should loop through all 100 sales districts, '* BUG (DMS 3/10/02) calling the function RetrieveInformation for each one, '* BUG (DMS 3/10/02) but it only does the first 90 sales districts and then '* BUG (DMS 3/10/02) stops. For i = 1 to 100 RetrieveInformation(i) Next
The debugging comments in the preceding snippet include the reviewer s initials and the date the comment was added. This facilitates communication between the script writer and the reviewer. In addition, it helps ensure that no unneeded comments are left in the finished code; a debugging comment added years earlier is unlikely to still be valid and should be deleted.
To ensure that you remove all debugging comments from a script, you can use a second script to remove them. The script shown in Listing 18.3 removes debugging comments by doing the following:
Listing 18.3 Removing Debugging Comments
|
|
Send us your feedback | « Previous | Next » |