From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 20-APR-1992 01:30:19.42
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Wanted - callable F$environment

In article <1992Apr13.151327.1@cc.curtin.edu.au>, crobw@cc.curtin.edu.au writes:
> Is it possible for a high-level language, e.g. Fortran, to determine the full
> file specification of the .COM file from which it is running? In other words, I
> need something like a callable f$environment.
                        ^^^^^^^^^^^^^^^^^^^^^^
That would be useful.  However, the following piece of code does what you
requested.
	Dale
P.S. CMKRNL required.
 ----------------------------------------------------------------------------
 | Dale O. Miller                          | #   #  ###  #     ####         |
 | University of Arkansas at Little Rock   | #   # #   # #     #   #        |
 | 2801 S. University                      | #   # ##### #     ####         |
 | Little Rock, AR  72204-1099  USA        | #   # #   # #     #  #         |
 | (501)569-8714                           |  ###  #   # ##### #   #        |
 | DOMILLER@UALR.EDU, DOMILLER@UALR.BITNET | Disclaimer: This does not      |
 | 92-20-28 W,34-43-30 N.ICBMNET           | say what I say it doesn't say. |
 ----------------------------------------------------------------------------

	.TITLE CHECKDIR
	.IDENT /1.0/
;-------------------------------------------------------------------------------
;
;	This routine returns the name of the currently executing command
;	procedure.
;
;	Call with the address of a string descriptor.
;	Status is returned in R0
;
;-------------------------------------------------------------------------------

	.LIBRARY /SYS$LIBRARY:LIB/	; Executive macro library
	.LINK 'SYS$SYSTEM:SYS.STB'/SELECTIVE_SEARCH
	.LINK "SYS$SYSTEM:DCLDEF.STB"/SELECTIVE_SEARCH

	$PCBDEF				; Process Control Block offsets
	$STSDEF				; Command Lang defs
	$UAIDEF
;-------------------------------------------------------------------------------

	.PSECT	CODE RD,NOWRT,PIC,EXE,LONG
	.ENTRY	CHECKDIR ^M<r6,r7,r8>		; Routine entry point
	movzwl	@4(ap),r6
	movl	4(ap),r7

        $CMEXEC_S ROUTIN=200$		;call the retreival code in EXEC mode
        BLBS	R0,5$			;quit if problem (nopriv)
	BRW	90$
5$:	MOVL	#SS$_NORMAL,R0
90$:	RET				; back to the caller

200$:   .WORD   0			; Exec entry point
        MOVAL   G^CTL$AG_CLIDATA, R1    ;get address of process's cli area
        MOVAL   @PPD$L_PRC(R1), R1      ;pointer to process permanent data
        MOVAL   @PRC_L_IDFLNK(R1), R1   ;   "    to indirect command file
        MOVAB   @IDF_L_FILENAME(R1), R1 ;   "    to command proc name
        MOVZBl  (R1), r8		;save length of name
        MOVC5   r8, 1(R1), #^A' ', -	;copy name--padded with blanks--
                r6, @4(r7)		; into passed string
        MOVZWL  #SS$_NORMAL, R0		; Set success
        RET				; Return from exec
;
	.END

