Host Automation Object Samples


Sample VBScript in HTML Page for use with BlueZone Web-to-Host Embedded Client

The following script is designed to be used with BlueZone Web-to-Host running in the Embedded Client Mode.  This script will launch an "embedded" BlueZone IBM 3270 Mainframe Display session from an Object Tag.  Five buttons will appear at the top of the web page.  Once the session is launched, you can use the buttons to perform several functions:

If you have an IBM 3270 Mainframe and you want to use the script as is, you will have to change the HostAddress value and possibly the Port value located in the Object Tag.

Also, you will have to change the Username and Password located in the LogOn function with your own valid Username and Password.

This sample script also contains the "ScriptOnInitComplere" PARAM shown here:

<PARAM NAME="ScriptLanguage" VALUE="VBScript">

<PARAM NAME="ScriptOnInitComplete" VALUE="hostConn">
 

The purpose of this PARAM is to delay the execution of your script until the BlueZone Web-to-Host Control Module and associated files are completely downloaded.  To use it, create a Function that launches your script.  Place that Function name in the PARAM VALUE as shown in the above example and in the sample script below.

To use the script, create a text document, name it anything you wish, and save it with a file extension of .htm or .html.  Copy and paste the HTML code into the document you just created.  Or, you can cut and paste the script into an existing HTML page.  Either way, since this page contains the Object Tag, this page will take the place of your current Object Tag page.

NOTE  In order to use this sample HTML page and script, you must have BlueZone Web-to-Host installed and running on a web server with the optional BlueZone scripting cab file made available to the End Users.

SEE  “How to Include BlueZone Scripting Components” located in the BlueZone Web-to-Host Administrator’s Guide in the “How To Guide – Scripting Related” section, for more information.

Also, In order for the BlueZone Host Automation Object to communicate with a BlueZone Display emulation session, you must enable BlueZone's DDE interface.

SEE  Configuring BlueZone to Work with the Host Automation Object

NOTE  If you want the script to automatically Log On to the host, un-comment the last two lines of the hostConn Function.  The last two lines contain the words "else" and "logOn".  By un-commenting these two lines, the function "hostConn will automatically call the Function logOn.

Differences Between VBScript and JavaScript

There are a few syntax and usage differences between VBScript and JavaScript.

SEE  Sample JavaScript in HTML Page for use with BlueZone Web-to-Host Embedded Client for more information.


Sample HTML Page with VBScript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE>VBScript Sample Page</TITLE>

 

<SCRIPT language="VBScript">

 

Dim Host, Row, Col

 

' create Function hostConn which is called by "ScriptOnInitComplete" in the Object Tag

Function hostConn

 

' instantiate the BlueZone Object

Set host = CreateObject( "BZWhll.WhllObj" )

ResultCode = host.Connect( "A" )

 

If ( ResultCode <> 0 ) Then

 

' display an error message if it can't connect

host.MsgBox "Error connecting to session A!", 4096

 

End If

 

End Function

 

' log on to the host

Function logOn

 

host.Wait 1

host.SendKey "TSO"

host.SendKey "@E"

host.Wait 1

host.WaitReady 10, 1

host.SendKey "username"

host.SendKey "@E"

host.WaitReady 10, 1

host.SendKey "password"

host.SendKey "@E"

host.WaitReady 10, 1

host.SendKey "@E"

host.WaitReady 10, 2

host.SendKey "@E"

host.WaitReady 10, 1

host.Focus

 

End Function

 

' *** GetCursor Example ***

Function getCursor

 

host.GetCursor Row, Col

host.MsgBox "The Row = "& Row & " , the Column = "& Col, 4096

host.Focus

 

End Function

 

' *** ReadScreen Example ***

Function readScreen

 

host.ReadScreen Buf, 8, 6, 19

host.MsgBox "Buf is "& Buf, 4096

host.Focus

 

End Function

 

' log off from host

Function logOff

 

host.SendKey "@3"

host.WaitReady 10, 1

host.SendKey "logoff@E"

host.WaitReady 10, 1

host.focus

host.CloseSession 0, 1

host.Focus

 

End Function

 

' disconnect the BlueZone Object

Function disconnObj

 

host.MsgBox "BZHAO Disconnected!", 4096

host.disconnect

 

End Function

 

</SCRIPT>

</HEAD>

<BODY>

 

<DIV Style="Position:Absolute;Left:10px;Top:50px">

 

<OBJECT ID="Seagull Web-to-host Control Module v3"

CLASSID="clsid:037790A6-1576-11D6-903D-00105AABADD3"

CODEBASE="../controls/sglw2hcm.ocx#Version=-1,-1,-1,-1"

HEIGHT=480

WIDTH=740

>

<PARAM NAME="IniFile" VALUE="default.ini">

<PARAM NAME="Sessions" VALUE="MD_S1">

<PARAM NAME="DistFile" VALUE="default.dst">

<PARAM NAME="MD_S1" VALUE="mainframe.zmd">

<PARAM NAME="MD_S1_Save" VALUE="Yes">

<PARAM NAME="ScriptLanguage" VALUE="VBScript">

<PARAM NAME="ScriptOnInitComplete" VALUE="hostConn">

<PARAM NAME="MD_S1_RunInBrowser" VALUE="Position">

</OBJECT>

 

</DIV>

 

<FORM>

<INPUT NAME="submit" TYPE=Button VALUE="Log On" onClick="logOn">

<INPUT NAME="submit" TYPE=Button VALUE="Perform GetCursor" onClick="getCursor">

<INPUT NAME="submit" TYPE=Button VALUE="Perform ReadScreen" onClick="readScreen">

<INPUT NAME="submit" TYPE=Button VALUE="Log Off" onClick="logOff">

<INPUT NAME="submit" TYPE=Button VALUE="Disconnect" onClick="disconnObj">

</FORM>

 

</SCRIPT>

</BODY>

</HTML>