MQCURMSGS()

From Lianjapedia
Revision as of 06:48, 28 March 2017 by Yvonne.milne (Talk | contribs)

Jump to: navigation, search

Purpose

Return the number of unread messages in the specified queue

Syntax

MQCURMSGS(<expN>)

See Also

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

Description

The MQCURMSGS() function returns the current number of unread messages in the open queue specified by <expN>. 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().

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)