- Command names are case sensitive and must be used appropriately.
- Variable names are also case sensitive, for example, countyName and countyname are not the same variable.
- In most scripting languages the formatting of the script is a critical process, this includes the use of indention of lines.
- The concepts of this module will be executed in immediate mode and not in programing mode. When a return (enter) is pressed in immediate mode the scripting line is executed, an exception would be when working with a looping function.
Any item that follows the pound sign (#) is a comment and will have no effect on the execution of a program line.
- At the beginning of a script the author, organization and what the program does should be defined. This is important both for the author and those that the script might be shared with, the author might have forgotten what the scripts purpose was and thus some simple metadata could save time.
- Comments should be used to name the program operation, but also used to separate parts of the program and what their functional purpose is, this makes for easier troubleshooting and modifications. The name of the program or section of the program should be descriptive, there are no character limitations.
- Many times when code is written on a multiple step program, there are errors and the author may not know where the actual problem(s) are located. Placing a comment tag in front of a line of operational code will eliminate the code from the operation, but not delete the line. If the program functions without the line of code, then this is the location of the problem which can be edited to solve the issue. Multiple lines of code can be commented out (pound sign placed in front of each line).
- A comment can be placed on a blank line as a separator. No text is required after the pound sign so it can also be used to break up sections of the program.
The comments shown in Figure 1 have the following purposes.
- The name of the program is a critical component, the date the script was created (written) and/or modified is also important.
- What are the rights of someone wanting to use a particular script is also a critical concern. It is suggested that you allow others to use your scripts since this is part of an open learning community. It is important that you know your employer policies on making scripts available to individuals outside of the organization. It is suggested when possible to make the script have a Creative Commons notation.
- The last line might be placed in the body of the program to explain what is being accomplished in that specific location in the script. Programs may include hundreds of lines of text, none created for this course will be of this size.
- By using comment statements, it will be easier to edit and modify your script. Many times scripts are created, used and not used again for several weeks or months; the comments will make it possible to understand the functional purpose of the script.