home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
FINDSESS.ZIP
/
FINDSESS.CMD
Wrap
OS/2 REXX Batch file
|
1991-06-05
|
2KB
|
95 lines
/* REXX
** Return the next available VTAM session or null if no
** available session.
*/
'@ECHO off'
/*
** Get command line input. Set trace if requested.
*/
parse upper arg trace .
if trace = 'TRACE' then do
trace ?r
end
call program_initialization
if \find_open_presentation_space() then do
say
say 'No open sessions found.'
short_name = ''
end
exit short_name
/*
** End of Mainline
*/
program_initialization:
/*
** Initialize variables, set boolean switches, strip leading
** and trailing blanks from input parms (if necessary) , etc.
*/
/*
** load REXHLAPI.DLL external function if not already loaded
*/
if rxfuncquery('REXHLLAPI') then do
call rxfuncadd 'REXHLLAPI','REXHLAPI', 'REXHLLAPI'
end
true = 1
false = 0
session_in_use = true
short_name = ''
vtam_prompt = 'SALT RIVER PROJECT NETWORK TERMINAL'
return
find_open_presentation_space:
say
say 'Querying Sessions...'
session_info = REXHLLAPI('Query_sessions')
if length(session_info) < 13 then do
say 'No host sessions are active.'
return false
end
say
say 'Searching for open host session...'
say
do start_pos = 1 by 12 for (length(session_info) / 12) while session_in_use
session_type = substr(session_info,start_pos+9,1)
if session_type = 'H' then do
short_name = substr(session_info,start_pos,1)
long_name = substr(session_info,start_pos+1,8)
call check_session
end
end
if session_in_use then do
return false
end
else do
return true
end
check_session:
say 'A Checking host session' short_name '-' long_name
if REXHLLAPI('Connect_ps', short_name) = 0 then do
if REXHLLAPI('Search_ps', vtam_prompt, 1) <> 0 then do
say
say 'Open session' short_name 'found.'
session_in_use = false
end
call REXHLLAPI 'Disconnect_ps'
end
return