home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
epm603a.zip
/
EPMSMP.ZIP
/
EHLLAPI.E
< prev
next >
Wrap
Text File
|
1992-08-26
|
9KB
|
194 lines
; The following contains samples of various EHLLAPI calls to
; allow EPM to interact with the Communications Manager. This
; is a stand-alone file; note that E3EMUL.E includes both the
; HLLAPI_CALL routine and a simpler interface for calls that
; don't return data.
; By Larry Margolis
compile if not defined(CREATEBUF)
include 'STDCONST.E'
compile endif
defc gethost -- Get a copy of the host screen
EHLLAPI_data_string = 'A' -- *** Connect to host PS ***
EHLLAPI_data_string_length = atoi(1) -- Data string length or buffer size
EHLLAPI_host_PS_position = atoi(0) -- Host presentation space position
result=HLLAPI_call(atoi(1),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
if result then
sayerror 'Error' result 'trying to connect to host session A.'
stop
endif
; *** Copy host presentation space ***
bufhndl = buffer(CREATEBUF, 'HLLAPI', 1920) -- get a buffer; assume 24x80
if not bufhndl then
sayerror 'CREATEBUF error number 'RC
call EHLLAPI_DISC()
stop
endif
EHLLAPI_data_string_length = atoi(1920)
EHLLAPI_host_PS_position = atoi(1) -- N/A
result=HLLAPI_call(atoi(5), atoi(bufhndl), atoi(0),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
-- (on return, RC)
if result=0 | result=4 | result=5 then
cur_pos = .line+1
do i=0 to 1840 by 80
insertline peek(bufhndl, i, 80),cur_pos
cur_pos=cur_pos+1
end
else
sayerror 'Error' result 'trying to copy host screen.'
endif
success = buffer(FREEBUF, bufhndl)
if not success then sayerror 'FREEBUF error number 'RC; endif
call EHLLAPI_DISC() -- *** Disconnect from host presentation space ***
defc send_LAMSERV -- Send the LAMSERV command to the host screen
EHLLAPI_data_string = 'A' -- *** Connect to host PS ***
EHLLAPI_data_string_length = atoi(1) -- Data string length or buffer size
EHLLAPI_host_PS_position = atoi(0) -- Host presentation space position
result=HLLAPI_call(atoi(1),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
if result then
sayerror 'Error' result 'trying to connect to host session A.'
stop
endif
; *** Send key sequence to host ***
EHLLAPI_data_string = '@R@0@B@FLAMSERV@E'
; Reset, Home, Backtab, Erase_EOF, 'LAMSERV', Enter
; Should work from XEDIT as well as Ready prompt. (Untested.)
EHLLAPI_data_string_length = atoi(length(EHLLAPI_data_string))
EHLLAPI_host_PS_position = atoi(0) -- N/A
result=HLLAPI_call(atoi(3),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
if result then
sayerror 'Error' result 'trying to send LAMSERV command.'
stop
endif
call EHLLAPI_DISC() -- *** Disconnect from host presentation space ***
defc testqs = -- code 10 = Query sessions
EHLLAPI_data_string = substr('',1,120)
EHLLAPI_data_string_length = atoi(120) -- Data string length or buffer size
EHLLAPI_host_PS_position = atoi(0) -- Host presentation space position
result=HLLAPI_call(atoi(10),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
; rc = itoa(EHLLAPI_host_PS_position,10)
insertline EHLLAPI_data_string
sayerror 'Result =' result 'and RC =' itoa(EHLLAPI_host_PS_position,10) 'and length =' itoa(EHLLAPI_data_string_length,10)'.'
defc testqss = -- code 22 = Query session status
EHLLAPI_data_string = substr('A',1,18)
EHLLAPI_data_string_length = atoi(18) -- Data string length or buffer size
EHLLAPI_host_PS_position = atoi(0) -- Host presentation space position
result=HLLAPI_call(atoi(22),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
; rc = itoa(EHLLAPI_host_PS_position,10)
insertline EHLLAPI_data_string
rows = itoa(substr(EHLLAPI_data_string,12,2),10)
cols = itoa(substr(EHLLAPI_data_string,14,2),10)
sayerror 'Result =' result 'and RC =' itoa(EHLLAPI_host_PS_position,10) 'and size =' rows 'x' cols'.'
defc testcon = -- code 1 = Connect to presentation space
EHLLAPI_data_string = 'A'
EHLLAPI_data_string_length = atoi(1) -- Data string length or buffer size
EHLLAPI_host_PS_position = atoi(69) -- Host presentation space position
result=HLLAPI_call(atoi(1),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
; rc = itoa(EHLLAPI_host_PS_position,10)
sayerror 'Result =' result 'and RC =' itoa(EHLLAPI_host_PS_position,10)'.'
defc testcopystring = -- code 15 = Copy string
parse arg posn strng
EHLLAPI_data_string = strng
EHLLAPI_data_string_length = atoi(length(strng)) -- Data string length
EHLLAPI_host_PS_position = atoi(posn) -- Host presentation space position
result=HLLAPI_call(atoi(15),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
sayerror 'Result =' result 'and RC =' itoa(EHLLAPI_host_PS_position,10)'.'
defc testsendkey = -- code 3 = Send key
EHLLAPI_data_string = arg(1)
EHLLAPI_data_string_length = atoi(length(arg(1))) -- Data string length
EHLLAPI_host_PS_position = atoi(0) -- N/A
result=HLLAPI_call(atoi(3),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
sayerror 'Result =' result 'and RC =' itoa(EHLLAPI_host_PS_position,10)'.'
defc testdisc = -- code 2 = Disconnect from presentation space
result= EHLLAPI_DISC()
sayerror 'Result =' result
defproc EHLLAPI_DISC
EHLLAPI_data_string = ''
EHLLAPI_data_string_length = atoi(0) -- Data string length or buffer size
EHLLAPI_host_PS_position = atoi(0) -- Host presentation space position
return HLLAPI_call(atoi(2),
selector(EHLLAPI_data_string), offset(EHLLAPI_data_string),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
defc test_copy_PS= -- code 5 = Copy presentation space
; EHLLAPI_data_string = substr('',1,1920) -- Assume 24x80 screen
bufhndl = buffer(CREATEBUF, 'HLLAPI', 1920) -- get a buffer
if not bufhndl then sayerror 'CREATEBUF error number 'RC; stop; endif
EHLLAPI_data_string_length = atoi(1920)
EHLLAPI_host_PS_position = atoi(1) -- N/A
result=HLLAPI_call(atoi(5), atoi(bufhndl), atoi(0),
EHLLAPI_data_string_length, EHLLAPI_host_PS_position)
-- (on return, RC)
cur_pos = .line+1
if result=0 | result=4 | result=5 then
do i=0 to 1840 by 80
insertline peek(bufhndl, i, 80),cur_pos
cur_pos=cur_pos+1
end
endif
sayerror 'Result =' result 'and RC =' itoa(EHLLAPI_host_PS_position,10)'.'
success = buffer(FREEBUF, bufhndl)
if not success then sayerror 'FREEBUF error number 'RC; stop; endif
; HLLAPI_call is the general interface for calling the EHLLAPI dynalink.
; Parameters are always the same - an EHLLAPI function number, selector of
; the data string, offset of the data string, the data string length, and
; the host presentation space position. They might not be used in all calls,
; but EHLLAPI requires that they all be present.
;
; The data string is passed via selector and offset rather than as a VAR string,
; since some calls (e.g., copying the entire host screen) require a string
; larger than 255 bytes, and so we must allocate a buffer and pass that.
defproc HLLAPI_call(EHLLAPI_function_number,
sel_EHLLAPI_data_string, ofs_EHLLAPI_data_string,
var EHLLAPI_data_string_length, -- Data str. len. or buffer size
var EHLLAPI_host_PS_position) -- Host presentation space posn.
-- (on return, RC)
rc = 0 -- Prepare for missing DLL library
result=dynalink('ACS3EHAP', /* dynamic link library name */
'HLLAPI', /* HLLAPI direct call */
selector(EHLLAPI_function_number)||
offset(EHLLAPI_function_number)||
sel_EHLLAPI_data_string||
ofs_EHLLAPI_data_string||
selector(EHLLAPI_data_string_length)||
offset(EHLLAPI_data_string_length)||
selector(EHLLAPI_host_PS_position)||
offset(EHLLAPI_host_PS_position))
if rc then sayerror 'Error' rc 'from HLLAPI dynalink call.'; stop; endif
return result