|
Guy recommends :
Find out which of your VMs are a waste of space and which VMs need more resources. |
VBScript - Hungarian VariablesIntroduction to Hungarian VariablesBefore we see the advantages of using the Hungarian Variable scheme, let us review what the term variable means in the context of VBScript. What is a VBScript Variable?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 Hungarian conventionThe 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.
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. Hungarian Convention Example:A VBScript to create 10 Computer Accounts for machines called WKStation1 to WKStation10.
VBScript to demonstrate the Hungarian Convention Notes: The variable used here is ComputerNum What our variable ComputerNum does is just add a number to the constant WKStation. An inelegant alternative would be to have 5 lines dedicated to creating each computer account. By using a variable, if you wanted 50 computers beginning with WKStation, it would be easy to amend the script. Change For ComputerNum = 1 to 10 --> For ComputerNum = 1 to 50.
Guy
Recommends: Permissions Analyzer - Free Active Directory Tool
|
||||
Custom Search
|
Guy Recommends: WMI Monitor and It's Free!
|
|
Home Copyright © 1999-2012 Computer Performance LTD All rights reserved Please report a broken link, or an error. | |