Difference between revisions of "MQRECEIVE()"

From Lianjapedia
Jump to: navigation, search
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Get a message from an open message queue
 
Get a message from an open message queue
 
  
 
==Syntax==
 
==Syntax==
 
MQRECEIVE(<expN>)
 
MQRECEIVE(<expN>)
 
  
 
==See Also==
 
==See Also==
 
[[MQCLOSE()]], [[MQCREATE()]], [[MQCURMSGS()]], [[MQOPEN()]], [[MQSEND()]], [[MQUNLINK()]], [[XML_DECODE()]], [[XML_ENCODE()]], [[XML_GATHER()]], [[XML_SCATTER()]]
 
[[MQCLOSE()]], [[MQCREATE()]], [[MQCURMSGS()]], [[MQOPEN()]], [[MQSEND()]], [[MQUNLINK()]], [[XML_DECODE()]], [[XML_ENCODE()]], [[XML_GATHER()]], [[XML_SCATTER()]]
 
  
 
==Description==
 
==Description==
Line 17: Line 14:
  
 
For more examples of handling message queues, please see the examples/mqueue programs in the software distribution.
 
For more examples of handling message queues, please see the examples/mqueue programs in the software distribution.
 
  
 
==Example==
 
==Example==
Line 39: Line 35:
 
mqclose(mqdes)
 
mqclose(mqdes)
 
</code>
 
</code>
 
  
 
==Products==
 
==Products==

Revision as of 13:03, 11 December 2012

Purpose

Get a message from an open message queue

Syntax

MQRECEIVE(<expN>)

See Also

MQCLOSE(), MQCREATE(), MQCURMSGS(), MQOPEN(), MQSEND(), MQUNLINK(), XML_DECODE(), XML_ENCODE(), XML_GATHER(), XML_SCATTER()

Description

The MQRECEIVE() function gets a message from an open message queue. It returns the message as a character string. If an error occurs and it is unable to get the message, it returns an empty string and the ERRNO() function can be checked to determine the error. The <expN> is the pointer to a queue opened with MQCREATE() or MQOPEN().

The MQCLOSE() function is used to close a queue which has been opened with MQOPEN() or MQCREATE().

For more examples of handling message queues, please see the examples/mqueue programs in the software distribution.

Example

// Open up the queue for reading
mqdes=mqopen("/myqueue")
if (mqdes < 0)
    messagebox(strerror()+",errno="+alltrim(str(error())))
    return
endif
// do while there are messages
do while (mqcurmsgs(mqdes) > 0)
    // Get each message
    mstr=mqreceive(mqdes)
    if (empty(mstr))
        messagebox(strerror()+",errno="+alltrim(str(error())))
        return
    endif
    messagebox(mstr)
enddo
mqclose(mqdes)

Products

Lianja, Lianja Server