From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 12-JUN-1991 18:51:31.49
To:	ARISIA::EVERHART
CC:	
Subj:	Re: Mailboxes.

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.100)
	 id AA17593; Wed, 12 Jun 91 18:12:10 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Wed, 12 JUN 91 10:11:53 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA13145; Wed, 12 Jun 91 10:06:44 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 12 Jun 91 10:08:09 GMT
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!merrimack.edu!rand@ucbvax.Berkeley.EDU
Organization: Merrimack College, No. Andover, MA
Subject: Re: Mailboxes.
Message-Id: <1991Jun12.100810.22011@merrimack.edu>
References: <17574.284bd324@ul.ie>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <17574.284bd324@ul.ie>, 9025189@ul.ie writes:
> 
> 			Hello Netters,
> 				Does anybody know how to handle mailboxes in DCL
> (is it possible to create them in dcl?) or a high level language equivilant.

This was discussed at the last DECUS symposium by Skip Morris of DEC. Here
is his spawn hack.

$ vfy = f$verify(0+"''debug'")
$!+
$! CREATE_MBX.COM E2.1 (Create a mailbox for use from DCL)
$!
$!      Skip Morris, "SWSVAX::MORRIS", 9-July-1986
$!      Based (stolen) from ideas by Jerry Leichter, Dave Lennig & ELIS::Garson
$!
$!      This procedure creates and opens a mailbox for use from DCL.  The
$!      mailbox is given the process logical name DCL_MBX.  If it is run
$!      multiple times, extra mailboxes are given the names DCL_MBXnn.
$!
$!      RESTRICTION: The MAXIUM RECORD SIZE is limited to 16 bytes!!! (I
$!      have no idea why and haven't had time time to figure it out.)
$!-
$ my_pid = f$getjpi("","pid")
$ if f$leng(p1) .gt. 0 then goto subprocess
$ count = ""
$! allow for multiple mailboxes to be created (not to exceed 32 total)
$ sanity_count = 0
$loop:
$ sanity_count = sanity_count + 1
$ if sanity_count .ge. 32 then exit 4
$ if f$trnlnm("dcl_mbx''count'") .eqs. "" then goto spawn
$ count = f$stri(f$inte(count)+1)
$ goto loop
$spawn:
$ dcl_mbx = "dcl_mbx" + count                           ! logical name used
$ procedure = f$envi("procedure")
$! spawn a subprocess creating a mailbox...
$ spawn/nolog/nowait/process=crembx_'my_pid' @'procedure' 'my_pid' 'count'
$ set process/suspend/id=0
$ mailbox = "mba" + f$trnlnm(dcl_mbx)
$ open/read/write 'dcl_mbx' 'mailbox':                  ! grab mailbox
$ deassign/job 'dcl_mbx'                                ! remove job logical
$ stop crembx_'my_pid'                                  ! kill subprocess
$ write sys$output "%CREMBX-I-CREATED, Mailbox ",dcl_mbx, -
    " ",f$trnlnm(dcl_mbx),": created."
$ exit 1+0*f$verify(vfy)
$!
$subprocess:
$ mailbox = f$getjpi("","tmbu")
$ define/nolog/job dcl_mbx'p2' 'mailbox'                ! tell parent mbx name
$loop:
$ set process/resume/id='p1'
$ wait 00:00:01.50
$ if f$extr(0,3,f$getjpi(p1,"state")) .eqs. "SUS"
$  then
$    sanity_check = f$inte("''sanity_check'")+1
$    if sanity_check .gt. 256 then exit %x4
$    goto loop
$  endif
$ set process/suspend/id=0
$ exit 4+0*f$verify(vfy)

