Mailbox Examples

This section contains a few brief examples of GT.M mailbox handling.

Example:

    SET mb="FASTREPORT" O mb:PRMMBX u mb
    FOR READ msg QUIT:msg="$STOP$" DO print(msg)
    QUIT
    

This OPENs "FASTREPORT" as a permanent mailbox. "FASTREPORT" is the logical name that translates to the mailbox specification. Generally the system manager creates permanent mailboxes as part of system start-up. If this is not the case, the process running our example requires PRMMBX and SYSNAM privileges.

Example:

    SET mb="SYNC" OPEN mb:(TMPMBX:WRITEONLY) USE mb:WAIT
    SET x="" WRITE "$START$",$J
    FOR SET x=$O(^tmp($J,x)) q:x="" WRITE ^(x)
    WRITE "$END$"
    CLOSE mb
    

This OPENs "SYNC" as a temporary mailbox for synchronous writes. If "SYNC" does not exist as a temporary mailbox in the GROUP logical name table of our process, GT.M creates a mailbox and places "SYNC" in the GROUP table. Creating "SYNC" requires TMPMBX and GRPNAM privileges. The process executing the example waits for another process to read each of its writes. If no other process reads from the mailbox, the process hangs indefinitely.