Adapting WSH Examples for ASP

Although the interface reference examples are written for the Windows Scripting Host (WSH), you can easily adapt them for Active Server Pages (ASP). The first step is to wrap the VBScript code in the ASP delimiters (<% and %>), as in the following example:

WSH File ASP File
 
Option Explicit 
On Error Resume Next 
Dim objSearchAdmin 
Set objSearchAdmin = _
CreateObject("Search.SearchAdmin.1") 
... 
'Release objSearchAdmin object 
Set objSearchAdmin = Nothing 
<% 
Option Explicit 
On Error Resume Next 
Dim objSearchAdmin 
Set objSearchAdmin = _
CreateObject("Search.SearchAdmin.1") 
... 
'Release objSearchAdmin object 
Set objSearchAdmin = Nothing 
%>

Also, to produce output, you must change the Wscript.Echo methods to Response.Write methods.

Note   Since ASP files default to the VBScript programming language, you need not supply a language qualifier to your VBScript ASP pages. If you use a different language, such as JScript, you must amend the first line of the previous ASP example to the following:

<% SCRIPT LANGUAGE="JScript"
 

ASP files offer some additional functionality over WSH files. For example, you can create an include file in which can place commonly-used code, such as the following defined constants, which specify the error codes you receive if Search cannot create the object or the object does not exist:

Const E_CREATEOBJECT  = 429   ' cannot create object 
Const E_NOTEXIST      = 424   ' object doesn't exist 
 

You can then include this file in an ASP file with a line of code similar to the following, where SearchInclude.inc is the name of the include file (it can be any legal file name and need not have the .inc file extension):

<!--#include file = "SearchInclude.inc"-->

© 1997-1998 Microsoft Corporation. All rights reserved.