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:
C:\JOBLOG.TXTTo modify and use the script:
|
1. |
Create a text document and name it anything you want. Save the file with a .js extension.
|
|
2. |
Copy and paste the entire script into the document you just created. |
|
3. |
Copy the script into the BlueZone \scripts folder.
|
|
4. |
Launch the BlueZone Script Host and Debugger program. |
|
5. |
Select from the menu bar.
|
|
6. |
Locate the script you just created and highlight it and click Open.
The script appears in the BlueZone Script Host and Debugger main window.
|
|
7. |
Create a BlueZone configuration that connects to your iSeries host and be sure to enable the DDE interface. |
|
8. |
Name the configuration iseries.zad.
|
|
9. |
Replace username and password in the script below with a valid username and password.
|
// 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@Tpassword@E" )
host.WaitReady( 10, 1 )
// go to Display Job Log screen
host.SendKey( "1@E" )
host.WaitReady( 10, 1 )
host.SendKey( "1@E" )
host.WaitReady( 10, 1 )
host.SendKey( "10@E" )
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( "@E" )
host.WaitReady( 10, 1 )
host.SendKey( "@3" )
host.WaitReady( 10, 1 )
host.SendKey( "90@E" )
host.WaitReady( 10, 1 )
// close BlueZone iSeries Display having session id of S1
host.CloseSession( 1, 1 )