This script is designed to be used with BlueZone for the desktop. The script launches an already existing BlueZone iSeries (AS/400) configuration called iseries.zad, navigates to the end user's job log, and writes the contents of the job log to a file and store it in the following location:
The script appears in the BlueZone Script Host and Debugger main window.
// Sample JScript using BlueZone Host Automation Object // This sample script will run a BlueZone session and then // logon to an iSeries host and write the Job Log to the disk // file C:\JOBLOG.TXT. // Instantiate a handle to BlueZone Host Automation Object host = new ActiveXObject( "BZWhll.WhllObj" ) // Run BlueZone iSeries Display with session ID of S1 // Timeout and return error if no signon screen after 30 seconds // Continue with script execution after host sends 1 screen paint ResultCode = host.OpenSession( 1, 1, "warrenton.zad", 30, 1 ) if ( ResultCode != 0 ) host.MsgBox( "Error launching BlueZone session!", 4096 ) // connect to session with hllapi id of "A" // return error if session not found else ResultCode = host.Connect( "A" ) if ( ResultCode != 0 ) host.MsgBox( "Error connecting to session A!", 4096 ) // logon to host // then wait for host to unlock the keyboard host.SendKey( "username<Tab>password<Enter>" ) host.WaitReady( 10, 1 ) // go to Display Job Log screen host.SendKey( "1<Enter>" ) host.WaitReady( 10, 1 ) host.SendKey( "1<Enter>" ) host.WaitReady( 10, 1 ) host.SendKey( "10<Enter>" ) host.WaitReady( 10, 1 ) // create disk file C:\JOBLOG.TXT var ForReading = 1, ForWriting = 2, ForAppending = 3 var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 var fs, f, ts // create the joblog file fs = new ActiveXObject( "Scripting.FileSystemObject" ) fs.CreateTextFile( "c:\\joblog.txt" ) f = fs.GetFile( "c:\\joblog.txt" ) ts = f.OpenAsTextStream( ForWriting, TristateUseDefault ) // read the screens until "More..." is NOT found at position row 19, column 74 var MoreText = "More.." var BottomText = "Bottom" var Buf = new Object( ) if ( MoreText != BottomText ) host.ReadScreen( Buf, 1920, 1, 1 ) // write the contents of the buffer to the screen // host.MsgBox( Buf.Str, 64 ) // optional message box // write the contents of the buffer to disk ts.Write( Buf.Str ) ts.Write( " " ) host.ReadScreen( MoreText, 6, 19, 74 ) // close the file ts.Close( ) // logoff from host host.SendKey( "<Enter>" ) host.WaitReady( 10, 1 ) host.SendKey( "<PF3>" ) host.WaitReady( 10, 1 ) host.SendKey( "90<Enter>" ) host.WaitReady( 10, 1 ) // close BlueZone iSeries Display having session id of S1 host.CloseSession( 1, 1 )