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="JavaScript"> <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. Either way, 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. Also, 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().
Some scripting languages such as JScript and JavaScript only support passing variable parameters to functions as Values (copies), as opposed to passing variable parameters to functions as References (pointers). In these scripting environments, parameters passed to functions that return data need to be of type "Object". The BlueZone Host Automation Object has built-in support for passing variables of type Object to its methods that return data, and uses the reserved object members "Str" and "Num" to "fill-in" the data to be returned. In the following Sample HTML Page, there are examples of the ReadScreen and Get Cursor Methods using correct JavaScript syntax.. The ReadScreen Method returns a string of text so "Str" has to be used, and the GetCursor Method returns a number value so "Num" has to be used.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>JavaScript Sample Page</TITLE> <SCRIPT language="JavaScript" type="text/javascript"> // create function hostConn() which is called by "ScriptOnInitComplete" in the Object Tag function hostConn() { // instantiate the BlueZone Object host = new ActiveXObject( "BZWhll.WhllObj" ); ResultCode = host.Connect( "A" ); if ( ResultCode != 0 ) //display an error message if can't connect host.MsgBox( "Error connecting to session A!", 48 ); } // log on to the host function logOn() { 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(); } // *** GetCursor Example *** function getCursor() { var Row = new Object(); var Col = new Object(); host.GetCursor( Row, Col ); alert( "The Row = " + Row.Num + ", the Column = " + Col.Num ); host.Focus(); } // *** ReadScreen Example *** function readScreen() { var Buf = new Object(); host.ReadScreen (Buf, 8, 6, 19); alert( "The contents of Buf = " + Buf.Str ); host.Focus(); } // *** ReadScreen Example *** function readScreen() { var Buf = new Object(); host.ReadScreen (Buf, 8, 6, 19); alert( "The contents of Buf = " + Buf.Str ); host.Focus(); } // disconnect the BlueZone Object function disconnObj() { alert ( "BZHAO Disconnected!" ); host.disconnect(); } </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="JavaScript"> <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>