From:	CSBVAX::MRGATE!carl@CitHex.Caltech.Edu@SMTP 23-MAR-1988 10:15
To:	ARISIA::EVERHART
Subj:	RE: Chaining images... THE source


Received: from CitHex.Caltech.Edu by KL.SRI.COM with TCP; Sun 20 Mar 88 19:57:57-PST
Date:     Sun, 20 Mar 88 19:58:34 PST
From:     carl@CitHex.Caltech.Edu (Carl J Lydick)
Message-Id: <880320194658.77b@CitHex.Caltech.Edu>
Subject:  RE: Chaining images... THE source
In-Reply-To: Your message dated 18-Mar-1988
To:       SUTTON%BRANDEIS.BITNET@CitHex.Caltech.Edu,
         info-vax@CitHex.Caltech.Edu

 > I got a message a few minutes ago (I wonder how many days it will be before
 > this message gets to people), saying that it is not possible in a practical
 > sense to "chain images".  That is, "CALL" one image from another as  if  it
 > were  just  a  subroutine.   I  didn't think it was possible either until a
 > message came in referring everyone to the LIB$FIND_IMAGE_SYMBOL routine (my
 > apologies  to  the  person  who  posted it, I don't remember your name).  I
 > wanted to see if it REALLY did  what  the  manual  seemed  to  say  it  did
 > (sometimes  the routine descriptions which don't include examples are vague
 > or I'm simply too dumb to understand without an example).  I looked in  the
 > Master  Index to see if there were any references to the routine other than
 > the description in the RTL  manual.   There  were  none  and  therefore  no
 > examples (I assume) in the manuals.

I'm one of the people who referred you to LIB$FIND_IMAGE_SYMBOL.  Let me point
out  again  that  this  works only with SHAREABLE images.  This means that you
can't chain most images that are linked to be run via a command from  the  DCL
level.   However,  I've  discovered  that  it is possible to run at least some
shareable images via a DCL command; for example, TEST1, below, can be run that
way, as well as by being called from TEST0).  Here's a complete example of how
to use LIB$FIND_IMAGE_SYMBOL from a VAX C program, including  both the calling
and the called program.

Create a file, TEST0.C with the contents
/******************************* TEST0.C BEGINS *******************************/
#include descrip                  

main()
{	$DESCRIPTOR(filename,"TEST1");
	$DESCRIPTOR(symbol_desc,"test1");
	int (*fubar)() = 0, stat;

	if (((stat = LIB$FIND_IMAGE_SYMBOL(&filename,&symbol_desc,&fubar))
		& 7) != 1)
		exit(stat);
	else
		(*fubar)();
	puts("Goodbye, world!");
}
/******************************** TEST0.C ENDS ********************************/
Compile it with the command:
	$ CC TEST0
Link it with the commands:
	$ LINK TEST0,SYS$INPUT:/OPT
	SYS$SHARE:VAXCRTL/SHARE
	^Z
Create a file, TEST1.C, containing:
/******************************* TEST1.C BEGINS *******************************/
test1()
{	puts("Hello, world!");
	return(1);
}
/******************************** TEST1.C ENDS ********************************/
Compile it:
	$ CC TEST1
Link it:
	$ LINK/SHARE TEST1,SYS$INPUT:/OPT
	SYS$SHARE:VAXCRTL/SHARE
	UNIVERSAL=test1
	^Z
Define a logical name pointing to TEST1
	$ DEFINE TEST1 'F$ENVIRONMENT("DEFAULT")'TEST1
Then run TEST0:
	$ RUN TEST0
Note that TEST1 can also be run from the DCL level:
	$ RUN TEST1
Hope this is useful to you.
