Adapting WSH Examples for ASP

Although the object 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 your VBScript code in the ASP delimiters (<% and %>), as in the following example:

WSH File ASP File
 

Option Explicit

On Error Resume Next

dim ReplClient

Set ReplClient = CreateObject("CrsApi.ReplicationClient")

... 'Do some replications

'Release Client object

ReplClient = Nothing

<%

Option Explicit

On Error Resume Next

dim ReplClient

set ReplClient = CreateObject("CrsApi.ReplicationClient")

... 'Do some replications

'Release Client object

ReplClient = 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 are all of the defined states for the ReplicationInstance.State property:

const REPL_STATE_EMPTY      = 0
const REPL_STATE_STARTING   = 1
const REPL_STATE_RUNNING    = 2
const REPL_STATE_COMPLETE   = 3
const REPL_STATE_ABORTED    = 4
const REPL_STATE_CANCELED   = 5
const REPL_STATE_RECEIVING  = 6
const REPL_STATE_PENDING    = 7

You can then include this file in an ASP file with a line of code similar to the following, where CDinclude.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 = "CDinclude.inc"-->

Note   You must explicitly cast any whole number value that you assign to a global parameter to a 32-bit (long) integer with CLng(), as shown in the following example, which sets the Depth parameter (the depth of the replication) to 3 for project MyProject:

const OPEN_EXISTING_PROJECT  = 2

dim ReplServer, Proj, Depth 

set ReplServer = CreateObject("CrsApi.ReplicationServer")
ReplServer.Initialize("")

set Proj = ReplServer.OpenProject("MyProject", OPEN_EXISTING_PROJECT)

Depth = Clng(3)
Proj.Put("Depth", Depth)

'Release objects
set ReplProject = Nothing
set ReplServer  = Nothing

© 1997-1998 Microsoft Corporation. All rights reserved.