Using VBScript as a Client


 

The following program illustrates the use of the PL/B Automation Sever by a VBScript client. Start by creating a simple HTML page containing a textarea and a button as follows:

 

<p><textarea name="ShowData" rows="10" cols="40"></textarea></p>

<input type="button" name="FillBut" value="Get The Smiths">

 

Next, the actual object tag for the component is added as:

 

<p><object id="PlbProg"

classid="CLSID:4E6D6AA0-6D28-11d4-B417-0000B43D1661"

align="baseline" border="0" width="50" height="50"></object>

 

This tag creates a PL/B Automation Server program object named PlbProg when a browser loads the HTML page. The following VBSCRIPT is then added:

 

<p><script language="VBScript"><!--

 

  PlbProg.Run("sampsrv")

 

Sub PlbProg_Exit( ok )

  text = ShowData.value & "Program has exited" & vbNewLine

  ShowData.value = text

End Sub

 

Sub PlbProg_UserEvent1( p1, p2, p3, p4, p5 )

  text = ShowData.value & p1 & p2 & vbNewLine

  ShowData.value = text

End Sub

 

Sub PlbProg_UserEvent2( p1, p2, p3, p4, p5 )

  text = ShowData.value & "No more matches" & vbNewLine

  ShowData.value = text

  PlbProg.EventSend 2

End Sub

 

Sub FillBut_OnClick

  PlbProg.EventSend 1, "Smith"

End Sub

 

--></script></p>

 

The script starts by running the "sampsrv" PL/B component program. It then contains three routines to handle the events from the PlbProg program object. The Exit event simply places the line "Program has exited" into the ShowData textarea. The UserEvent1 event takes the first two parameters (name and phone number) and places them into the ShowData textarea. The UserEvent2 event places the line "No more matches" into the ShowData textarea and then tells the component to exit.

 

The script also contains code for the OnClick event of the button. This code tells the component to look up the names and phone numbers of any Smith’s.

 

A sample HTML page created with FrontPage Express is shown below:

 

<html>

 

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=iso-8859-1">

<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">

<title>Untitled Normal Page</title>

</head>

 

<body bgcolor="#FFFFFF">

 

<form method="POST">

<p><font size="5">Bill's Sample HTML Page Using PL/B</font></p>

</form>

 

<p><textarea name="ShowData" rows="10" cols="40"></textarea></p>

 

<p><object id="PlbProg"

classid="CLSID:4E6D6AA0-6D28-11d4-B417-0000B43D1661"

align="baseline" border="0" width="50" height="50"></object><input

type="button" name="FillBut" value="Get The Smiths"></p>

 

<p><script language="VBScript"><!--

 

  PlbProg.Run("sampsrv")

 

Sub PlbProg_Exit( ok )

  text = ShowData.value & "Program has exited" & vbNewLine

  ShowData.value = text

End Sub

 

Sub PlbProg_UserEvent1( p1, p2, p3, p4, p5 )

  text = ShowData.value & p1 & p2 & vbNewLine

  ShowData.value = text

End Sub

 

Sub PlbProg_UserEvent2( p1, p2, p3, p4, p5 )

  text = ShowData.value & "No more matches" & vbNewLine

  ShowData.value = text

  PlbProg.EventSend 2

End Sub

 

Sub FillBut_OnClick

  PlbProg.EventSend 1, "Smith"

End Sub

 

--></script></p>

 

<form method="POST">

  <p>&nbsp;</p>

</form>

</body>

</html>

 

 

See Also: Automation



Compiler and Runtime Options Using Visual Basic as a Client Using the PLBCGI Command