WSH supports two kinds of script files: what we might term simple script files, which were supported by WSH 1.0 and are suitable for simple scripting applications; and script files with XML code, which is more structured, far more powerful, and have a number of features of interest to more advanced programmers. In this section, we’ll examine how both types of script files can be used.
files written in VBScript usually have a
extension and contain only VBScript
language elements, along with references to the properties, methods,
and events belonging to objects instantiated by the script. XML tags
are not permitted within simple script files.
The program entry point of a simple script is the global area at the
top of the file, and program execution terminates after the last line
of code that is not contained within a function or a procedure has
executed. This is illustrated by the simple script in Example 7.1. Program flow begins with the
Dim statement on the first line and ends with the
MsgBox function call on the fourth line. The
fourth line also causes the
function to be executed before the
MultTwo function is never
executed, since it is not explicitly called by the first four lines
Example 7-1. Program Flow in a Simple WSH Script
dim iVar1, iVar2 iVar1 = 1 iVar2 = 2 msgbox AddTwo(iVar1, iVar2) ' Multiplies two numbers Function MultTwo(var1, var2) MultTwo = var1 * var2 End Function ...