home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
epm603a.zip
/
EPMSMP.ZIP
/
QUECALLS.E
< prev
next >
Wrap
Text File
|
1992-08-26
|
3KB
|
87 lines
; The following contains samples of dynalinking to the OS/2 queue
; function from EPM. These are building blocks for you to use in
; your own code.
; By Larry Margolis
qhand = ' '
result=dynalink('QUECALLS', -- Creating a queue
'DOSCREATEQUEUE',
selector(qhand)||offset(qhand)||
atoi('0')||
selector(queue_name)||offset(queue_name))
if result <> 0 then
sayerror 'Could not create queue: ' result
stop
endif
call dynalink('QUECALLS', 'DOSCLOSEQUEUE', qhand) -- Closing a queue
result=dynalink('QUECALLS', -- Writing to a queue
'DOSWRITEQUEUE',
qhand||
atoi('0')||
atoi(MAXBUFSIZE)||
atoi(bufhndl)||atoi('0')|| /* address of buffer */
atoi('0'))
if result <> 0 then
sayerror 'Could not write queue : ' result
call dynalink('QUECALLS', 'DOSCLOSEQUEUE', qhand)
endif
; The following code opens a queue, reads from it, and inserts each
; element of the queue (assumed to be an EPM buffer as defined by the
; buffer() opcode) into the current file.
pid=' '
qhand = ' '
result=dynalink('QUECALLS',
'DOSOPENQUEUE',
selector(pid)||offset(pid)||
selector(qhand)||offset(qhand)||
selector(queue_name)||offset(queue_name))
if result <> 0 then sayerror 'Could not open 'queue_name; stop; endif
/* Get number of items in queue */
nelements= ' '
result=dynalink('QUECALLS',
'DOSQUERYQUEUE',
qhand||
selector(nelements)||offset(nelements))
if result <> 0 then
sayerror 'Error query queue'queue_name
call dynalink('QUECALLS', 'DOSCLOSEQUEUE', qhand)
stop
endif
/* Read all the elements from queue */
qinfo=' '
esize=' '
eaddr=' '
eprty=' '
i=.line
lc=itoa(nelements,10)
do n=1 to lc
/* Read queue */
result=dynalink('QUECALLS',
'DOSREADQUEUE',
qhand||
selector(qinfo)||offset(qinfo)||
selector(esize)||offset(esize)||
selector(eaddr)||offset(eaddr)||
atoi('0')||atoi('1')||
selector(eprty)||offset(eprty)||
atoi('0')||atoi('0'))
if result <> 0 then
sayerror 'Error reading queue' queue_name
call dynalink('QUECALLS', 'DOSCLOSEQUEUE', qhand)
stop
endif
/* get access to buffer and insert it in current file */
bufhndl = itoa(substr(eaddr, 3, 2), 10)
call buffer(GETBUF, bufhndl)
call buffer(FREEBUF, bufhndl)
enddo
call dynalink('QUECALLS', 'DOSCLOSEQUEUE', qhand)