home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rxhll.zip
/
HOST.REX
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-10-28
|
6KB
|
230 lines
/* #include Host.rex */
/**
*** ┌──────────────────────────────────────────────────────────────────────┐
*** │ Host Routines │
*** └──────────────────────────────────────────────────────────────────────┘
**/
HostLogon: procedure
/**
*** This will logon to IBMLink. This call should be replaced with
*** 'HostIBMLinkLogon' but was kept here to support the older code.
**/
parse arg arguments
say '"HostLogon" calls should be replaced with "HostIBMLinkLogon" calls.'
call HostIBMLinkLogon arguments
return
HostLogoff: procedure
/**
*** This will logon to IBMLink. This call should be replaced with
*** 'HostIBMLinkLogoff' but was kept here to support the older code.
**/
parse arg arguments
say '"HostLogoff" calls should be replaced with "HostIBMLinkLogoff" calls.'
call HostIBMLinkLogoff arguments
return
HostEnterXY: procedure expose Host.
/**
*** This will position the cursor at a row and column and press the
*** Enter key.
**/
parse arg x, y .
rcode = HostCursorXY(x,y)
code = hllapi('Sendkey', '@E')
rcode = hllapi('Wait')
return code
HostCursorXY: procedure expose Host.
/**
*** This will position the cursor at the proper row and column
**/
parse arg x, y .
Position = hllapi('Convert_pos', Host.Session, x, y)
code = hllapi('Set_cursor_pos', Position)
return code
HostGetCursorPos: procedure expose x y Host.
/**
*** This will return the current cursor position in the global variables
*** x & y
**/
Position = hllapi( 'Query_cursor_pos' )
xy = hllapi( 'Convert_pos', Host.Session, Position )
parse var xy x y
return
HostPageDown: procedure expose Screen. Host.
/**
*** This will page down to the next screen and refresh the Screen.
*** stem variable with the new screen.
**/
code = hllapi('Sendkey', '@8')
rc = hllapi('Wait')
call HostScreenToStem
return
HostPageUp: procedure expose Screen. Host.
/**
*** This will page up to the previous screen and refresh the Screen.
*** stem variable with the new screen.
**/
code = hllapi('Sendkey', '@7')
rc = hllapi('Wait')
call HostScreenToStem
return
HostScreenToStem: procedure expose Host. Screen.
/**
*** This will get the current screen and break it into the stem
*** variable called Screen.
**/
call HostGetScreenSize
PresSpace = hllapi('Copy_PS_to_str', 1, (Screen.Rows * Screen.Cols))
do i = 1 to Screen.Rows
Screen.i = left(PresSpace, Screen.Cols)
PresSpace = substr(PresSpace, Screen.Cols+1)
end
return
HostGetScreenSize: procedure expose Host. Screen.
/**
*** This will fill the stem variable with the number of rows and
*** columns in the current screen.
**/
SessionStatus = hllapi('Query_session_status', Host.Session)
Screen.Rows = c2d(reverse(substr(SessionStatus, 12, 2)))
Screen.Cols = c2d(reverse(substr(SessionStatus, 14, 2)))
return
HostError: procedure expose Host.
/**
*** This will handle unexpected response errors from the host session
**/
arg code .
select
when code = 1001 then say 'Host could not process QUERY TIME command.'
when code = 1002 then say 'Can''t synch time on this host operating system.'
when code = 1003 then say 'Don''t know how to logon to this host operating system.'
when code = 1004 then say 'Invalid security type.'
otherwise say 'Unexpected response from host.'
end /* select */
call HapiDisconnect
exit
HostWaitFor: procedure expose Host.
/**
*** This will wait for a certain string to appear on the screen. Some
*** applications will unlock the keyboard while processing (e.g. most
*** VM applictions), so the HLLAPI code can't just wait for keyboard
*** unlock. This will check for a particular character string before
*** returning. If the string doesn't appear within the number of
*** seconds passed, it will return a '-1' return code.
**/
parse arg MaxSeconds, SearchString
sleeps = 0
do until pos <> 0
pos=hllapi('Search_ps', SearchString, 1)
call SysSleep 1
sleeps = sleeps + 1
if sleeps >= MaxSeconds then
return -1
end /* until */
return 0
HostLoadUploadFile: procedure expose Upload.
/**
*** This will read an entire file into storage by placing each line
*** into a stem variable called Upload. It will also translate the
*** "@" symbols to "@@" to keep the HLLAPI code from interpreting
*** the "@" as a command.
**/
parse arg File
i = 1
UploadFile = open(File, 'READ')
do while(lines(UploadFile) > 0)
Upload.i = MapSymbol(linein(UploadFile), "@", "@@")
i = i + 1
end /* while */
code = Close(UploadFile)
Upload.0 = i - 1
return
HostPA2: procedure expose Screen. Host.
/**
*** This will press PA2 and refresh the Screen. stem variable with the
*** new screen.
**/
code = hllapi('Sendkey', '@y')
rc = hllapi('Wait')
call HostScreenToStem
return
HostLogonClMenu: procedure expose Host.
/**
*** This will check to see if the session is at the Quality logo
*** or the CLMenu screen or the "Press Enter..." one-liner screen.
*** Upon exit, you will be placed at the CL/Menu screen.
**/
pos = hllapi('Search_ps','CLM095I - PRESS ENTER OR PF KEY TO GET CL/MENU DISPLAY',1)
if pos <> 0 then
do
rc=hllapi('Sendkey', '@E')
rc=hllapi('Wait')
end
pos = hllapi('Search_ps','To start, enter MENU ====>',1)
if pos <> 0 then
do
/* Enter the menu command */
call HapiClear
rc=hllapi('Sendkey', 'MENU@E')
rc=hllapi('Wait')
end
/* Wait for the CL/Menu main screen to appear. If it doesn't after */
/* a few retries, bomb out. */
code = HostWaitFor(10, '/L - LOGON TO VTAM APPLICATION')
if code = -1 then
call HostError
return