.NODE

WSH Language Elements

All the language elements listed in Table 7-29 have been added to Windows Script Host as of Version 2.0. They are XML elements that can be used in .wsf files and allow metadata about script-based applications to be embedded in the same file as the script

Table 7-29. WSH language elements

Element

Description

Defines error handling. It syntax is error="flag" debug="flag" ?> where flag is the string "True" or "False", "Yes" or "No", or the integers 1 or 0. The error attribute defines whether the user will be notified of errors; the debug attribute determines whether a debugger is launched when an error is raised. By default, both attributes are false.

Indicates that the contents of a file should be parsed as XML. Its syntax is version="version" [standalone="DTDflag"] ?> where version is a string in the format n.n that indicates the XML level of the file, and DTDflag is a Boolean value that indicates whether the XML file includes a reference to an external DTD. Since script files do not include DTDs, the value of this attribute must always be "yes." The ?> tag must be the first element in the file, and cannot be preceded by any blank lines. Its most common use is to indicate that the script file can be edited by an XML editor.

descriptiveText

Defines the purpose of a script. It is displayed when the WScript.ShowUsage method is called or the user adds the /? command-line switch when running the script. It is enclosed within the ... element.

exampleScript

Provides an example of a script's usage. It is displayed when the WScript.ShowUsage method is called or the user adds the /? command-line switch when running the script. It is enclosed within the ... element.

script

Defines an individual job within a script file containing one or more jobs. Its syntax is id="jobid"> where jobid is a string identifier that's unique within the file. Every element that appears within a ... tag applies to that job. An individual job can be invoked using the //Job command-line switch.

name
 helpstring=hlp
 type=type
 required=req
/>

Provides information about a named argument to a script. It is displayed when the WScript.ShowUsage method is called or the user adds the /? command-line switch when running the script. name is the argument's name. hlp describes the argument. type indicates the argument's type and can be string, boolean, or simple. req is a Boolean that indicates whether the argument is required or optional. The element must be enclosed within the ... element. The required element is used in displaying usage information, and name and helpstring are used to describe the named argument.


 

Defines a global object. Its syntax is id="objID" [classid="clsid:GUID" | progid="progID"] /> where objID is the name by which the object will be referred in the script or scripts, GUID is the CLSID of the class from which the object was created (as defined in HKEY_CLASSES_ROOTCLSID), and progID is the programmatic identifier of the class. Either one of GUID or ProgID must be present, but not both.

script

Indicates that a Windows Script Host (.ws) file contains multiple job definitions, as defined by the ... job> element. If a file contains only a single job, the element is optional.


 

Adds a reference to a type library, making its constants available to the script. Its syntax is [object="progid" | guid="LibID" ] [version="version"] /> where progid is the programmatic identifier of the type library, LibID is its GUID, and version is its version number. Either progid or TypeLibGUID must be present, but not both. Typically, this is element causes a good deal of difficulty, although it does work. While individual classes within type libraries do have programmatic identifiers, most type libraries do not, which means that you should specify the GUID by determining its value from a subkey of the HKEY_CLASSES_ROOT TypeLib key in the registry. In addition, version defaults to 1.0, which is rarely the version you'd want to use. Available versions are listed as subkeys of HKEY_CLASSES_ ROOTTypeLibLibID, where LibID is the type library's GUID.

id>
text or number

Defines a string or number as a resource that can be retrieved by its identifier rather than "hard-coded" throughout script. Among other uses, resources are invaluable in localizing applications. Resources can be retrieved using the getResource method, whose syntax is getResource(id) where id is the ID of the resource. The method returns a string containing the resource value.

runtimeInfo

Provides runtime information about a script when the WScript.ShowUsage method is called or the user adds the /? command-line switch when running the script. It must appear within the ... element and therefore can apply to only a single script. It in turn can contain , , , , and elements.


 

Defines the language in which a code block is written and optionally imports that code block from another file. Its syntax is

Part I: The Basics

Introduction

Program Structure

Data Types and Variables

Error Handling and Debugging

VBScript with Active Server Pages

Programming Outlook Forms

Windows Script Host 5.6

VBScript with Internet Explorer

Windows Script Components

Part II: Reference

Part III: Appendixes

Appendix A. Language Elements by Category

Appendix B. VBScript Constants

Appendix C. Operators

Appendix E. The Script Encoder

show all menu





Vbscript in a Nutshell
VBScript in a Nutshell, 2nd Edition
ISBN: 0596004885
EAN: 2147483647
Year: 2003
Pages: 335
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net