Datasheet

Chapter 1: A Quick Introduction to Programming
2
Documenting code
Advanced testing, debugging, and beta testing
Rollout and support
Think of this chapter as a brief introduction to the important building blocks of programming. It
certainly won’t make you an expert programmer overnight, but it will hopefully give you the know-how
you’ll need to get the most out of the rest of the book.
Variables and Data Types
In this section, you’ll quickly move through some of the most basic concepts of programming, in
particular:
Using variables
Using comments
Using built-in VBScript functions
Understanding syntax issues
Using Variables
Quite simply, a variable is a place in the computer memory where your script holds a piece (or pieces)
of information, or data. The data stored in a variable can be pretty much anything. It may be something
simple, like a small number, like 4, something more complex, like a floating-point number such as 2.3,
or a much bigger number like 981.12932134. Or it might not be a number at all and could be a word or
a combination of letters and numbers. In fact, a variable can store pretty much anything you want it
to store.
Behind the scenes, the variable is a reserved section of the computer’s memory for storing data. Memory
is temporary — things stored there are not stored permanently like they are when you use the hard
drive. Because memory is a temporary storage area, and variables are stored in the computer’s memory,
they are therefore also temporary. Your script will use variables to store data temporarily that the script
needs to keep track of for later use. If your script needs to store that data permanently, it would store it
in a file or database on the computer’s hard disk.
To make it easier for the computer to keep track of the millions of bits of data that are stored in memory
at any given moment, the memory is broken up into chunks. Each chunk is exactly the same size, and
is given a unique address. Don’t worry about what the memory addresses are or how you use them
because you won’t need to know any of that to use VBScript, but it is useful to know that a variable is
a reserved set of one or more chunks. Also, different types of variables take up different amounts of
memory.
In your VBScript program, a variable usually begins its lifecycle by being declared (or dimensioned)
before use.
c01.indd 2c01.indd 2 8/27/07 7:45:17 PM8/27/07 7:45:17 PM