Difference between revisions of "MQCURMSGS()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
{{YLM to do}}
 
 
==Purpose==
 
==Purpose==
 
Return the number of unread messages in the specified queue
 
Return the number of unread messages in the specified queue
Line 9: Line 8:
  
 
==See Also==
 
==See Also==
[[MQCLOSE()]], [[MQCREATE()]], [[MQOPEN()]], [[MQRECEIVE()]], [[MQSEND()]]
+
[[MQCLOSE()]], [[MQCREATE()]], [[MQOPEN()]], [[MQRECEIVE()]], [[MQSEND()]], [[MQUNLINK()]], [[XML_DECODE()]], [[XML_ENCODE()]], [[XML_GATHER()]], [[XML_SCATTER()]]
  
  
 
==Description==
 
==Description==
The MQCURMSGS() function returns the current number of unread messages in the queue specified by <expN>.
+
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().
 +
 
 +
For more examples of handling message queues, please see the examples/mqueue programs in the software distribution.
  
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
 +
// Open up the queue for reading
 
mqdes=mqopen("/myqueue")
 
mqdes=mqopen("/myqueue")
 
if (mqdes < 0)
 
if (mqdes < 0)
  messagebox(strerror()+",errno="+alltrim(str(error())))
+
    messagebox(strerror()+",errno="+alltrim(str(error())))
  return
+
    return
 
endif
 
endif
 +
// do while there are messages
 
do while (mqcurmsgs(mqdes) > 0)
 
do while (mqcurmsgs(mqdes) > 0)
  mstr=mqreceive(mqdes)
+
    // Get each message
  if (empty(mstr))
+
    mstr=mqreceive(mqdes)
      messagebox(strerror()+",errno="+alltrim(str(error())))
+
    if (empty(mstr))
      return
+
        messagebox(strerror()+",errno="+alltrim(str(error())))
  endif
+
        return
  messagebox(mstr)
+
    endif
end do
+
    messagebox(mstr)
 +
enddo
 
mqclose(mqdes)
 
mqclose(mqdes)
 
</code>
 
</code>
 +
  
 
==Products==
 
==Products==

Latest revision as of 10:09, 5 July 2011

Purpose

Return the number of unread messages in the specified queue


Syntax

MQCURMSGS(<expN>)


See Also

MQCLOSE(), MQCREATE(), MQOPEN(), MQRECEIVE(), MQSEND(), 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().

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

Recital, Recital Server