The following script is designed to be used with BlueZone Web-to-Host running in the embedded client mode. This script launches an embedded BlueZone IBM 3270 Mainframe display session from an Object Tag. Five buttons appear at the top of the web page. Once the session is launched, you can use the buttons to perform the following functions:
If you have an IBM 3270 Mainframe and you want to use the script as is, you must change the HostAddress value and possibly the Port value located in the Object Tag.
Also, you must change the Username and Password located in the LogOn function with your own valid user name and password.
<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.
You can also cut and paste the script into an existing HTML page. Since this page contains the Object Tag, this page takes the place of your current Object Tag page.
Refer to the “How to Include BlueZone Scripting Components” section in the BlueZone Web-to-Host Administrator’s Guide for more information.
In order for the BlueZone Host Automation Object to communicate with a BlueZone Display emulation session, you must enable the BlueZone DDE interface. Refer to Configuring BlueZone for more information on enabling the DDE interface.
If you want the script to automatically log on to the host, uncomment the last two lines of the hostConn Function. The last two lines contain the words "else" and "logOn". By uncommenting these two lines, the function "hostConn” automatically calls the Function logOn.
There are a few syntax and usage differences between VBScript and JavaScript.
Refer to Sample JavaScript HTML for more information.
<!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 "<Enter>" host.Wait 1 host.WaitReady 10, 1 host.SendKey "username" host.SendKey "<Enter>" host.WaitReady 10, 1 host.SendKey "password" host.SendKey "<Enter>" host.WaitReady 10, 1 host.SendKey "<Enter>" host.WaitReady 10, 2 host.SendKey "<Enter>" 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 "<PF3>" host.WaitReady 10, 1 host.SendKey "logoff<Enter>" 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="BlueZone Web-to-host control module v5" CLASSID="clsid:037790A6-1576-11D6-903D-00105AABADD3" CODEBASE="../controls/bzw2h32.cab#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>