From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 30-JUL-1993 08:30:39.19
To:	EVERHART
CC:	
Subj:	Re: lib$find_image_symbol run-time routine

From: hoadley@merlin.anu.edu.au (David Hoadley)
X-Newsgroups: comp.os.vms
Subject: Re: lib$find_image_symbol run-time routine
Date: 29 Jul 1993 00:13:01 GMT
Organization: Mt. Stromlo and Siding Spring Observatories
Lines: 63
Message-Id: <2374md$nsn@manuel.anu.edu.au>
Nntp-Posting-Host: 150.203.89.16
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET

In article <14361446@MVB.SAIC.COM> "RWTMS1::GRAZIANI" 
   <GRAZIANI%RWTMS1.decnet@rockwell.com> writes:
>Does anyone have any sample code, in any language except Macro, 
>which uses the LIB$FIND_IMAGE_SYMBOL run-time library routine?  
>Documentation on this routine is incredibly scarce.

Here is another simple example of using LIB$FIND_IMAGE_SYMBOL, this time
using Pascal. It is extracted from a useful little program we have here.
It is possibly unusual in that LIB$FIS is being used to return the
addresses of blocks of data, rather than the addresses of routines.

On our VAX we maintain a writable shareable image called TCN_Database--it's
not a database, it just contains record structures--which our telescope
control system processes use in driving the telescope. This is protected
against all access by general users, for obvious safety reasons. But it
contains accurate time, which all (astronomical) users might want. So we
have this little program, which produces this output:
$ time
Civil Time:  29-JUL-93 09:39:31.4    Sidereal Time: 06:02:12.7
UTC:         28-JUL-93 23:39:31.8    MJD:           49196.985785

It is a privileged program, to get around the protection. But it needs to be
running before it can map to the shareable image. If it were linked to
the shareable image in the usual way, it would fail to load, with the usual
protection problems, as if it were non-privileged. So we use
LIB$FIND_IMAGE_SYMBOL, as follows:

[INHERIT(
    'SYS$LIBRARY:PASCAL$LIB_ROUTINES',
    'tel_library:tellib' )]	{  <--- defines types TEL_JT_Time and
				    TEL_JT_Site_Control }
PROGRAM Time_Display( Output );

CONST
    TCN_Database = 'TCN_DATABASE';	{ <-- the "TCN_DATABASE" logical name
    					   already exists }
VAR
    Time_Ptr : ^TEL_JT_Time;
    Ctl_Ptr  : ^TEL_JT_Site_Control;
{*
*  Within TCN_Database, record TCN_GR_Time_Data is defined to be of type
*  TEL_JT_Time, and TCN_GR_Control_Data is of type TEL_JT_Site_Control
*  Both are UNIVERSAL symbols.
*}
BEGIN { Time_Display }
LIB$FIND_IMAGE_SYMBOL( TCN_Database, 'TCN_GR_TIME_DATA', %REF Time_Ptr );
LIB$FIND_IMAGE_SYMBOL( TCN_Database, 'TCN_GR_CONTROL_DATA', %REF Ctl_Ptr );

IF NOT Ctl_Ptr^.Control_Program_Running THEN
    WRITELN( '%TCN-E-NOTRUNNING, central telescope control program not running' )
ELSE
    WITH Time_Ptr^ DO
	BEGIN
{    display the relevant fields of TCN_GR_Time_Data }
	END; { WITH }

END.  { Time_Display }

-- 
-------------------------------------------------------------------------------
David Hoadley                         INTERNET: hoadley@mso.anu.edu.au
Mount Stromlo Observatory,            Tel: +61 6 249-0288  Fax: +61 6 249-0233
The Australian National University, Canberra, Australia

