Introduction to Hungarian Variables
Before we see the advantages of using the Hungarian Variable scheme, let us review what the term variable means in the context of VBScript.
A variable is the opposite of a constant. Values of variables
change, constants remain at their initial value. Think of variables are
placeholders for items that will change during the script. By
declaring and using variables in your VBScripts, you can manipulate their values later.
Technically the computer reserves a place in memory for each variable.
Counters would be a classic use of a variable. If you wanted to
create 10 computers and put them all in same OU, you could use a variable
and then make the script loop ten times. The result ten computers and
an efficient script.
The idea is to give extra information about the type of variable.
What the Hungarian convention does is to lay down a three letter prefix
which instantly tells you what information to expect from the variable.
For example, if the variable represents text then it begins with str. Convention dictates that three letters are lowercase.
- int - Integer. Example intComputerNum representing 10 or 50
- str - String. Example strOU or strDomain
- obj - Object. Example objUser or objComputer
There are other less common variables, for instance: err - error, dtm - date,
boo - Boolean.
A variation of the Hungarian Convention is to use a one letter prefix s
for string, o for object.
|