Documenting Your Scripts with Comments and Creating a Script Template
|
|
|
|
| Articles Reviews Microsoft Windows | |
| Written by Adi Bach | |
| Saturday, 16 December 2006 | |
|
{mos_sb_discuss:42} Adding comments to your Windows scripts makes them easier for other peopleto understand. Comments provide you with the ability to embed documentationwith a script so that you can explain how and why you wrote it the way that youdid. Adding comments to scripts is a little bit like adding a trail of bread crumbs.
They give you something to follow if you find that you need to fix or modify ascript sometime down the road.Comments are added to Windows shell scripts using the REM statement, which hasthe following syntax: Comment is a text string representing the documentation that you wish to embed in the script. REM statements have no impact on the execution of your script. The Windows shell ignores them during script execution. You can use the REM statement in either of two ways. One way to use the REM statement is to include it on a line by itself to describe or document the action of one or more statements that follow, as demonstrated below. A second way to use the REM statement is to place it at the end of another statement, as demonstrated below. Creating a Script Template @ECHO off In this example, the template begins with the @ECHO off statement and then uses the REM statement to format a script header in which you can document information about the script, including its name, author, creation date, and a description. By using the template I have provided or by creating one of your own, you lay down a foundation for all future script development with a consistent organizational structure that will be easy to follow and update. For example, the following script demonstrates how to use the template in the creation of a new script. @ECHO off
COLOR F0 REM Subroutine and Procedure Section Note that while this particular example does not have any subroutines or procedures, you might still want to include that section comment in the script as a placeholder for possible future development. Powered by jReviews |
|
| Last Updated ( Friday, 08 June 2007 ) | |
| < Prev | Next > |
|---|







