From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 25-MAY-1993 11:51:33.29
To:	EVERHART
CC:	
Subj:	Re: Communication between processes using mailboxes...?

X-Newsgroups: comp.os.vms
From: michael@chpc.utexas.edu (Michael Lemke)
Subject: Re: Communication between processes using mailboxes...?
Message-Id: <1993May24.195618.22944@chpc.utexas.edu>
Organization: The University of Texas System - CHPC
Date: Mon, 24 May 93 19:56:18 GMT
Lines: 68
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET

In article <1993May24.160823.27273@iitmax.iit.edu> SYSFALKE@chico.acc.iit.edu (Falke Bruinsma) writes:
>I am writing a menu program in Pascal and to run the options I use the 
>command: lib$spawn('@program.com')
>However this is very slow and time/ resource comsuming since it has to 
>create and destroy a subprocess everytime you want to run a program. I 
>was wondering how I can improve this. I was thinking about creating a
>subprocess and keep it idle and as soon as I want to execute a program
>I would execute it in the subprocess. The communication between those 
>two processes would be through mailboxes.
>I have tried figuring out how to do this, but to no avail. Does anyone
>have an example on how to do this? Or could someone write a short program
>that does this? 
>Any help would be greatly appreciated!
>

 Here's a little FORTRAN routine which does what you want.  Either 
translate to Pascal or call directly from Pascal.  But I don't know how 
you have to declare the string in Pascal as I don't speak Pascal.


	integer function vmscmd(cmd,lc)

c       modified 1986 Oct 23 to take advantage of much simpler system call
C ***
C ***	Modifications:
C ***
C ***	28-FEB-1992 04:58:51.80		ML / UT Austin.  Keep process alive
C ***                                   between separate calls.
C ***
C ***	CMD	CHARACTER  readonly     DCL line to pass to process
C ***   LC	INTEGER	   readonly     length of CMD
C ***
C ***   VMSCMD	INTEGER	   function     status of various system services
C ***                      return 
C ***

	implicit none
	character*255   cmd
	integer         lc

	include '($clidef)'
	integer         lib$spawn, sys$crembx, lib$get_lun

	integer		mbx_chan, mbx
	data 		mbx_chan /-1/
	save 		mbx_chan

	if( mbx_chan .eq. -1 ) then
	   vmscmd = sys$crembx( , mbx_chan, ,,,, 'MONGO_BOX' )
	   if( vmscmd ) then
	      vmscmd = lib$get_lun( mbx )
	      open( mbx, file = 'mongo_box', 
     >            status = 'new', carriagecontrol = 'list', recl = 255 )
	      vmscmd = lib$spawn( , 'MONGO_BOX',
     >                                                  , cli$m_nowait )
           end if
	   if( .not. vmscmd ) then
	      mbx_chan = -1
	      return
	   end if
	end if

	write( mbx, '(a)' ) cmd(1:lc)	   
	end
-- 
Michael Lemke
Astronomy, UT Austin, Texas
(michael@io.as.utexas.edu or UTSPAN::UTADNX::IO::MICHAEL [SPAN])

