From:	MERC::"uunet!WKUVX1.BITNET!MacroMan" 16-JUN-1992 12:27:54.82
To:	MACRO32@WKUVX1.BITNET
CC:	
Subj:	Re: Can I get the creation date/time of the image I am running?

I see that Hunter already replied, but since I had a routine already
written, I thought I would share it with y'all.  I found only one
difference between what Hunter wrote and what I had done, and that
difference is commented in the code below.

The routine below returns the link date and time as a character
string. (It calls SYS$ASCTIM for you.)  I use it in programs which have
a /VERSION qualifier so I can easily see the build time of the program.

Have at it.  :)  (It's old.)

-Derek S. Haining
 University Computing Services
 University of Washington
 Seattle, Washington  98195
 (206) 543-5579

 DEREK@MAX.BITNET
 DEREK@MAX.U.WASHINGTON.EDU
;**************************************************************************
        .TITLE  GET_LINK
        .IDENT  "V01"
;++
;
;  Author:
;
;       Derek S. Haining
;
;  Creation Date:
;
;       26 January 1988    "V01"
;
;  Revisions:
;
;       None yet.
;
;  Functional Description:
;
;       This subroutine detemrines the link date and time for the
;       currently executing program.  It is designed to be used by
;       a program to determine "version" information.
;
;  Calling sequence:
;
;       ISTAT = GET_LINK (link-time)
;
;          where "link-time" is the address of a character string
;          descriptor.
;
;          NOTE:  Because of the way VMS FORTRAN handles character
;                 functions, this routine may also be called via:
;
;                 CHARACTER * 23 GET_LINK, LINK
;                 LINK = GET_LINK ()
;
;  Return Status:
;
;       SS$_NORMAL      Everything is OK.
;
;       SS$_ACCVIO      Null argument passed.
;
;       SS$_INSFARG     Not enough arguments were passed.
;
;--
        .LIBRARY 'SYS$LIBRARY:LIB.MLB'
        .LINK    'SYS$SYSTEM:SYS.STB'

;
;  Include files:
;

        $IHDDEF         ; Image Header Descriptor definitions
        $IHIDEF         ; Image Header Identification definitions

        .PSECT  DATA,PIC,CON,REL,LCL,NOSHR,NOEXE,RD,WRT,LONG

LINKDATE:
        .ASCID  /                       /

        .PSECT  CODE,NOPIC,CON,REL,LCL,NOSHR,EXE,RD,NOWRT,LONG

        .ENTRY  GET_LINK,^m<>

        CMPW    (AP),#1                 ; Check for the argument
        BLSS    INSFRG

;  ---------------------------------------------
;  Verify that the arguments are accessable.
;   If not, return "ACCESS VIOLATION".
;
        MOVL    4(AP),R0                ; Point to return function descr
        BEQL    ACCVIO                  ; If argument not passed



;  ---------------------------------------------
;  OK.  Let's look at the Image activator's buffer area.
;
        MOVL    G^CTL$GL_IMGHDRBF,R0    ; R0 = address of image activator's
                                        ;      image header buffer.
        ADDL2   #12,R0                  ; Skip over some junk.

;******
;  Instead of the ADDL2, Hunter's code did:
;       MOVL    (R0),R0                         ; Get header address
;******

        MOVZWL  B^IHD$W_IMGIDOFF(R0),R1 ; R1 = Image Header Identification
                                        ;      Area offset

        ADDL2   #IHI$Q_LINKTIME,R1      ; R1 = Link date/time offset

        PUSHL   #0
        PUSHAB  (R0)[R1]                ; Link date and time
        PUSHL   4(AP)                   ; User's buffer
        PUSHL   #0

        CALLS   #4,G^SYS$ASCTIM         ; Convert from binary time to ASCII

        RET

ACCVIO: MOVZWL  #SS$_ACCVIO,R0          ; Return ACCESS VIOLATION
        RET                             ; Leave

INSFRG: MOVL    #SS$_INSFARG,R0         ; If not, return error
        RET                             ; Leave

        .END
