home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!engr.uark.edu!mbox.ualr.edu!backup.ualr.edu!domiller
- Newsgroups: comp.os.vms
- Subject: Re: Detecting directory of invoked .com
- Message-ID: <1992Dec25.203725.1@ualr.edu>
- From: domiller@ualr.edu
- Date: 25 Dec 92 20:37:25 GMT
- References: <1992Dec23.181631.29078@tigger.jvnc.net>
- Organization: University of Arkansas at Little Rock
- Nntp-Posting-Host: backup.ualr.edu
- Lines: 70
-
- In article <1992Dec23.181631.29078@tigger.jvnc.net>, fogelinc@Cyanamid.COM (Carl Fogelin) writes:
- >>
- >>> In a DCL program, I would like to be able to determine what directory the
- >>> invoked .com file is located in. I seem to remember a similar thread about
- >>> 6 - 8 months ago, so I hope someone remembers the solution.
- >>
- [...]
-
- > On a related note, is there any way from within an executable to determine the
- > name of the DCL command program which invoked said executable? If it makes a
- > difference, my executable was programmed in C. Again thanks.
- $ define flame_destination nla0:
-
- OK, I'll bite. The solution I use (subject to breakage with any major VMS
- update, use at your own risk, etc.) is:
-
- .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
-
- ----------------------------------------------------------------------------
- | 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. |
- ----------------------------------------------------------------------------
-