c-- styles for logos and headline links do not modify internet, red, or black styles -->
|
|
|
|
|
|
By Paul Lomax, Matt Childs & Ron
Petrusha
Reusable Code Libararies-Windows Script HostAlthough standard Windows Script host files (i.e., .vbs files) do not allow you to import other files, WSH
files with XML elements (i.e., .wsf files) do. Include
another file by using the
where sLanguage is "VBScript" (or any
other valid scripting language) and sFileName is
either an absolute or a relative path to the file to be excluded. Note that
using the The included file must be a standard WSH script file. It can contain only script, without any XML elements or tags. The include file is simply inserted into the .wsf file as if it were an intrinsic part of it. Examples 2-12 and 2-13 illustrate the use of an include file. In this case, the code in Example 2-13 imports Lib.vbs, the include file shown in Example 2-12. Example 2-12 simply displays a message box displaying drives and their free space. To retrieve this information, it calls the GetFreeSpace function, which is located in the include file. This function returns a Dictionary object whose keys are drive names and whose values are the amount of free space available on the respective drive. Example 2-12: Lib.vbs, an Include File
Example 2-13: A WSH Script That Uses an Include File
Note that files must be included on a per-job basis. In other
words, if a .wsf file contains multiple jobs, you must
have a separate Client-Side Scripts for MSIELike Windows Script Host, MSIE supports the
where sURL is the URL of the include file and sLanguage is the language in which the file designated by sURL is written. sLanguage can be "VBScript" or any other valid scripting language. The include file is simply inserted into the text stream on the
client at the point that the Example
2-14 contains an include file and Example
2-15 an HTML document that includes a client-side script to validate data.
Note that the IsBlank routine is visible to the web
page, since the included script is considered part of the original document.
Note also that Validate.inc contains only script,
without any HTML tags, and that the source document contains a
Example 2-15: A Web Page That Uses an Include File
|
|