Difference between revisions of "MQOPEN()"

From Recital Documentation Wiki
Jump to: navigation, search
Line 29: Line 29:
  
  
The MQCLOSE() function is used to close a queue which has been opened with MQOPEN().
+
The MQCLOSE() function is used to close a queue which has been opened with MQOPEN() or MQCREATE().
  
  
Line 46: Line 46:
 
     endif
 
     endif
 
     messagebox(mstr)
 
     messagebox(mstr)
end do
+
enddo
 
mqclose(mqdes)
 
mqclose(mqdes)
 
</code>
 
</code>

Revision as of 11:15, 19 November 2009

Purpose

Open a pointer to a message queue


Syntax

MQOPEN(<expC> [,<expN>])


See Also

MQCLOSE(), MQCREATE(), MQCURMSGS(), MQRECEIVE(), MQSEND()


Description

The MQOPEN() function opens an existing message queue. It returns a numeric pointer when the queue is opened successfully, or a -1 if unsuccessful. The <expC> is the name of the queue to open. Since the pointer is required to identify an open queue to other messaging functions, always assign the return value to a memory variable. The optional <expN> determines the queue access mode:


<expN> Access Mode
Unspecified Read only access
0 Read only access
1 Write only access
2 Read/Write access


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


Example

mqdes=mqopen("/myqueue")
if (mqdes < 0)
    messagebox(strerror()+",errno="+alltrim(str(error())))
    return
endif
do while (mqcurmsgs(mqdes) > 0)
    mstr=mqreceive(mqdes)
    if (empty(mstr))
        messagebox(strerror()+",errno="+alltrim(str(error())))
        return
    endif
    messagebox(mstr)
enddo
mqclose(mqdes)


Products

Recital, Recital Server