Wednesday, June 07, 2006

VBScript [draft]

What is VBScript?
Originally conceived as a web scripting language to provide some client-side validation and programmatic functionality to HTML pages (similar to JavaScript), VBScript has grown to become the scripting language of choice in many tools such as Mercury Interactive's QTP and Microsoft's Monad Shell.
By being a script language, VBScript is incredibly lightweight containing only a small number of keywords and operators, yet being able to support useful functionality.


HISTORY
=======
VBScript is related to the Visual Basic family of languages and bears a lot of syntactic similarities to the language. However, by being a script language, VBScript supports much less functionality than Visual Basic or Visual Basic.Net.


LANGUAGE CHARACTERISTICS
========================
Syntax - VBScript has English-like syntax reminiscent of such languages as COBOL, FORTRAN etc. This sets it apart from languages derived from C/C++ that have a heavy reliance on symbols.

Supports COM Objects - COM objects can be instanced and referenced from within VBScript giving the language considerable strength of functionality.
[Note: COM objects cannot be created in VBScript. ]

Interpreted - VBScript is an interpreted language requiring that the source code for the script be made available to the interpreter at runtime.


LANGUAGE CONTENT
=================
Comments - Used to explain code sections
Variables - Temporary storage for data
Constants - Permanent storage for data
Declaration - Reservation of space for a variable or constant
Naming Rules - The following 5 rules that must be followed to name items
1. Must begin with letter or underscore
2. Can't contain special characters except underscore
3. Can't be same as the keyword
4. Must be less than 255 characters long
5. Must be unique

Operators
* Arithmetic - Operators used for mathematical computation
* Relational - Use to compare 2 values against each other
* Logical - Used to simplify one or more boolean conditions
* Assignment - Used to store the value of an expression
* Concatenation - Uses to combine strings

Control Flow
* Branching - Allows sections of code to be skipped
+ If - Allows branching based on a set condition
+ Select - Allows branching based on the value of a variable
* Loops - Allows section of code to be repeated
+ While - Entry condition loop
+ Do...While - Exit condition loop
+ For - Iterated Loop
Functions
* Built-In - Code units provided with the VBScript language
* User Defined


OPERATORS
=========
Arithmetic
- Subtraction
+ Addition
/ Division
* Multiplication
^ Exponent
Mod Modulo

Relational
> Greater than
<>= Greater than or equal
<= Less than or equal = Equals <> Not equal

Logical
And
Or
Not

Assignment
= Assign

Concatenation
& Concatenate


KEYWORDS
========
Comments - ', Rem
Declaration - Dim, Const
If - If, Then, Else, ElseIf, End If
Select - Select, Case, Else, End Select
While - While, Wend
Do...While - Do, Loop, While
For - For, To, Step, Next, Exit
Function - Function, Sub, Byval, ByRef, Exit, End Function
Misc - Option Explicit, Option Compare Text, Option Compare Binary

USEFUL FUNCTIONS
================
Msgbox - Displays information
InputBox - Allows the application to accept input
Now - Returns the system date and time