Previous Section Table of Contents Next Section

Typographical Elements

Books on programming can benefit a great deal from easy-to-understand typestyles and elements like the ones I'll explain here. These typestyles and elements are designed to make the text easier to follow and to call your attention to special concerns.

Boldfaced type will be used to set off material that should be typed into the computer; boldfaced also will be used to signify onscreen menu and/or dialog box selections. For example, "select Run from the Start menu, type wbemtest, and click OK" sets off the menu selection, what you need to type onscreen, and what should be clicked from the dialog box.

Blocks of code and code lines that appear within the text will appear in a monospaced font, as in, "to change the contents of a variable, you can use something like Var1 = Trim(Var1)."

TIP

Tips will provide shortcuts and other "insider advice" about scripting that you'll find valuable.


NOTE

Notes will provide cautions and other clarifications that will help you avoid problems or further clarify complex concepts.


I'll also direct you to material that more thoroughly explains particular concepts, VBScript commands, and so forth. Although I'm not a big fan of flipping back and forth through a book, these cross-references will allow you to remain focused within each chapter and will guide you to more detailed explanations, when appropriate.

Finally, there are times when it is necessary to present an extended explanation of something that isn't critical to the task at hand. In those cases, I'll use a sidebar. A sidebar is a cue that the information is useful, but it's not really key to the main text; you're welcome to skip the sidebar and come back to it later if you like.

Sidebars

Sidebars make it easier to cover slightly off-topic information without distracting you from the main text.


graphics/arrow.gif Sample Scripts

Obviously, a book on scripting is going to have many code listings. To make these as useful as possible, I introduce each example script with a special head style, and present it in a listing by itself with no comments.

Listing P.1. A Sample Script. Accepts a name, and then redisplays that name.

'Get the user's name

sName = InputBox("What is your name?")



'Display the user's name

MsgBox "Your name is " & sName

After I present each script, I'll briefly review any changes you might need to make to get the script running in your environment, such as changing computer or domain names. You'll find each complete script included on the CD that accompanies this book. I've created a separate folder for each chapter and named the script files by their listing number for easy reference.

graphics/arrow.gif Sample Scripts-Explained

For each script in this book, I'll include a line-by-line explanation of the script, so that you understand exactly what's going on. For example:

First, the sample script will display a dialog box where the user can type his name. By default, this dialog box includes an OK and Cancel button; I'm not providing any way to detect the Cancel button in this script, so I'm assuming the user will type something and click OK.


'Get the user's name

sName = InputBox("What is your name?")

Finally, the script uses the MsgBox statement to redisplay the user's name. Notice the use of the ampersand operator (&) to tack on the contents of the variable sName, which stores whatever the user typed into the input box.


'Display the user's name

MsgBox "Your name is " & sName

Walk-throughs like this one will help you become more familiar with VBScript, what each command does, and exactly how each example script works.

    Previous Section Table of Contents Next Section