Chapter 3. The Components of a Script
IN THIS CHAPTER
When you started using Windows, you had to learn all kinds of new terms, like minimize and mouse. Scripting has a language all its own, too, and in this chapter, you'll learn the anatomy of a script and what some of those special terms mean.
Every good book has a structure. This book, for example, includes an introduction and some introductory chapters. Most of the book is taken up with explanatory chapters and examples. There's an appendix, an index, and a table of contents. All of these elements work together to make the book useful for a variety of purposes, including learning, referencing, and so forth.
Scripts have a structure, too. The main body of the script is a bit like its table of contents, organizing what the script will do. Functions and subroutines are the chapters of the book and perform the actual work. Finally, there are comments and documentation, which act as an index and help provide cross-references and meaning to the actual script code.
Do you really need to know these things to pump out a useful administrative script? Not at all. In fact, if your goal is to start programming as quickly as possible, skip ahead to the next chapter. However, understanding the structure of a good script can help make scripting easier, make your scripts more useful, and save you a lot of time and effort in the long run.
|