From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 28-JUL-1993 09:00:36.03
To:	EVERHART
CC:	
Subj:	Re: lib$find_image_symbol run-time routine

Date: Wed, 28 Jul 1993 12:51:43 +0100
From: Arne Vajhøj <ARNE@kopc.hhs.dk>
Subject: Re: lib$find_image_symbol run-time routine
To: GRAZIANI%RWTMS1.decnet@ROCKWELL.COM, INFO-VAX@SRI.COM
Message-id: <01H12RI19IIQ9LV8KX@kopc.hhs.dk>
X-VMS-To: KOPC::IN%"GRAZIANI%RWTMS1.decnet@ROCKWELL.COM"
X-VMS-Cc: IN::"INFO-VAX@SRI.COM"
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=ISO-8859-1
Content-transfer-encoding: 8BIT

> 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.

(What is wrong with MACRO ????)

Below is examples in FORTRAN, C and PASCAL (just cut and @):

$ set ver
$ ! FORTRAN
$ fortran/object=zz sys$input
      SUBROUTINE TEST
      WRITE(*,*) 'Hello'
      RETURN
      END
$
$ link/share zz+sys$input/opt
universal=test
$
$ fortran/object=z sys$input
      PROGRAM Z
      INTEGER*4 V
      CALL LIB$FIND_IMAGE_SYMBOL('ZZ','TEST',V,'SYS$DISK:[].EXE')
      CALL DUMMY(%VAL(V))
      END
C
      SUBROUTINE DUMMY(R)
      EXTERNAL R
      CALL R
      RETURN
      END
$
$ link z
$ r z
$ ! C
$ cc/object=zz sys$input
#include <stdio.h>

void test()
{
   printf("Hello\n");
}
$
$ link/share zz+sys$input/opt
sys$library:vaxcrtl/share
universal=test
$
$ cc/object=z sys$input
#include <descrip.h>

long lib$find_image_symbol();

main()
{
   long (*v)();
   $DESCRIPTOR(d1,"zz");
   $DESCRIPTOR(d2,"test");
   $DESCRIPTOR(d3,"sys$disk:[].exe");
   lib$find_image_symbol(&d1,&d2,&v,&d3);
   (*v)();
}
$
$ link z+sys$input/opt
sys$library:vaxcrtl/share
$
$ r z
$ ! PASCAL
$ pascal/object=zz sys$input
module zz(input,output);

[global] procedure test;

begin
   writeln('Hello');
end;

end.
$
$ link/share zz+sys$input/opt
universal=test
$
$ pascal/object=z sys$input
[inherit('sys$library:pascal$lib_routines')]

program z(input,output);

procedure dummy(r : integer);

(* I do not like the definition in SYS$LIBRARY:PASCAL$LIB_ROUTINES *)
[external] function lib$callg(%IMMED argument_list : integer := 0;
                              %IMMED user_procedure : integer):integer;external;

begin
   lib$callg(user_procedure:=r);
end;

var
   v : integer;

begin
   lib$find_image_symbol('zz','test',v,'sys$disk:[].exe');
   dummy(v);
end.
$
$ link z
$ r z
$ set nover
$ exit

Hope it helps !

                                                          Arne

Arne Vajhøj                             local DECNET:  KO::ARNE
Computer Department                     PSI:           PSI%238310013040::ARNE
Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK


