Tech News

VBSCRIPT LANGUAGE FUNDAMENTALS VBScript Variables, Constants, and Data Typing

Essential Language Elements

VBScript statements are line delineated, one statement per line unless special line continuation or statement separator characters are used. For this reason no end of statement character delimiter is used in VBScript. VBScript provides a typical set of arithmetic operators for addition, subtraction, division, and multiplication (+, −, /, ∗), as well as special arithmetic operators for no remainder integer division (\), remainder only modulo division (Mod), and exponentiation (∧). The string concatenation operator is “&” (though where unambiguous “+” can be used instead).

VBScript version 5.6 provides a rich set of program flow control constructs. Branching can be accomplished using block-style If . . . Then . . . Else and Select Case statements.

VBScript Coding Conventions

Over time, the community of programmers using any given language tends to develop conventions in areas such as naming patterns for variables and constants, the way program commentary is incorporated, and the way code is formatted and indented.

There are several recognized coding conventions used by VBScript programmers (Microsoft, 2002c). Two naming patterns are commonly used for named constants. One pattern specifies all upper case for names of constants. When using this pattern, individual words within the name of a constant are delineated using an underscore (thus, “MY CONSTANT NAME”).

OBJECTS IN VBSCRIPT Use of Objects in VBScript

Finally, the Dictionary object of the Microsoft Scripting Runtime Library allows you to store and manipulate lists of key value pairs, i.e., lists of values where each value is tied to a unique key. “Scripting.Dictionary” is the ProgID of the Dictionary object. This object has a small set of properties and methods that allow your script to add and remove items from the dictionary list, retrieve or alter individual values by key, change or replace individual keys, and check to see if a particular key exists in the dictionary list.

Windows Scripting Host Object Model

The WSH object model consists of a top-level object, WScript, with properties germane to the script and how it was invoked, methods for suspending and ending script execution and creating and using external objects, and a half-dozen immediate child objects, each providing access to a service or a function of the host system. WScript child objects include: WshArguments, a collection containing any command line arguments used when invoking the script; WshNetwork, providing access to network configuration and services; StdIn, StdOut, and StdErr, specialized read-only or write-only TextStream objects providing access to standard input and output devices.

ADVANCED FEATURES OF VBSCRIPT

Object classes enable encapsulation of programming code, which in turn facilitates modular development of applications and the reuse of code. While VBScript has long provided stable support for the use of object classes by script, mechanisms to support modular development and reuse of script itself were less stable and less robust prior to the release of VBScript version 5. VBScript now provides several ways of varying complexity and sophistication to modularize script development and deployment and facilitate script reuse. Discussed briefly in this section are three specific technologies that facilitate script modularization and reuse: Windows Script Files, Remote Scripting, and Windows Script Components. In addition, VBScript, as of version 5, supports class declaration statements, and these statements allow for the direct creation of fullblown object classes written entirely in VBScript.

CONCLUSION

VBScript has been and continues to be an important programming language. While simple and easy to implement and having relatively low overhead, it is a rich, powerful, and modern structured programming language with many of the best features of object-oriented programming languages included. As a kind of VBA for the Web it has been particularly important as the scripting language of choice for the development of server-side ASP pages run in the context of Microsoft’s IIS Web server. Though less ubiquitous and general purpose than JavaScript it can be useful in certain circumstances for client-side scripting of the Internet Explorer Web browser.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button