From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX"  8-JUN-1992 09:45:31.16
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: DCL Mailboxes

In article <1992Jun3.172349.22877@e2big.mko.dec.com>, winalski@tle.enet.dec.com (Paul S. Winalski) writes:

> There is no direct access to $CREMBX from DCL.  Somewhere along the way you
> have to write a .EXE to do the $CREMBX for you.  The tricky part then is to
> get the mailbox to stay around after the .EXE exits--you need a channel
> assigned to it in either supervisor mode or exec mode. 
> 
> This is not a trivial problem.
> 
Well, it may not be trivial, but it certainly isn't difficult if you tackle
it in a slightly different way.

CREMBX.COM:
$	crembx = "$sys$disk:[]crembx"
$	crembx 'p1			! Create mailbox
$	open 'p1 'p1 /read /write	! Open it as a PPF
$	write 'p1 "LOGOUT"		! Kill the subprocess keeping it alive

CREMBX.FOR:
	options		/extend_source
	program		crembx
	implicit	none

	include		'($IODEF)'
	integer		status, lib$get_foreign, sys$crembx, lib$spawn, sys$qiow
	integer *2	iosb(4)
	integer *2	channel
	character *1	null
	character *63	mailbox_name
	integer *4	mailbox_name_l / 0 /	! High word is always zero

	! Get the mailbox name
	status = lib$get_foreign ( mailbox_name,, mailbox_name_l )
	if ( .not. status ) call lib$stop ( %val(status) )

	! Create it
	status = sys$crembx ( ,channel,,,,,mailbox_name(1:mailbox_name_l), )
	if ( .not. status ) call lib$stop ( %val(status) )

	! Spawn a subprocess to keep mailbox alive after image exit
	status = lib$spawn ( ,mailbox_name(1:mailbox_name_l),'NLA0:',7 )
	if ( .not. status ) call lib$stop ( %val(status) )

	! Make sure the subprocess is alive and has the mailbox open
	status = sys$qiow ( ,%val(channel), %val(io$_writevblk),iosb,,,
	1		    %ref(null), %val(0),,,, )
	if ( .not. status ) call lib$stop ( %val(status) )
	if ( .not. iosb(1) ) call lib$stop ( %val(iosb(1)) )

	end

John Briggs			vaxs09@v7.vitro.com

