home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 19884 < prev    next >
Encoding:
Internet Message Format  |  1992-12-25  |  3.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!engr.uark.edu!mbox.ualr.edu!backup.ualr.edu!domiller
  2. Newsgroups: comp.os.vms
  3. Subject: Re: Detecting directory of invoked .com
  4. Message-ID: <1992Dec25.203725.1@ualr.edu>
  5. From: domiller@ualr.edu
  6. Date: 25 Dec 92 20:37:25 GMT
  7. References: <1992Dec23.181631.29078@tigger.jvnc.net>
  8. Organization: University of Arkansas at Little Rock
  9. Nntp-Posting-Host: backup.ualr.edu
  10. Lines: 70
  11.  
  12. In article <1992Dec23.181631.29078@tigger.jvnc.net>, fogelinc@Cyanamid.COM (Carl Fogelin) writes:
  13. >>
  14. >>> In a DCL program, I would like to be able to determine what directory the
  15. >>> invoked .com file is located in.  I seem to remember a similar thread about
  16. >>> 6 - 8 months ago, so I hope someone remembers the solution.
  17. >>
  18.  [...]
  19.  
  20. > On a related note, is there any way from within an executable to determine the
  21. > name of the DCL command program which invoked said executable?  If it makes a
  22. > difference, my executable was programmed in C.  Again thanks.
  23. $ define flame_destination nla0:
  24.  
  25. OK, I'll bite.  The solution I use (subject to breakage with any major VMS
  26. update, use at your own risk, etc.) is:
  27.  
  28.     .TITLE CHECKDIR
  29.     .IDENT /1.0/
  30. ;-------------------------------------------------------------------------------
  31. ;
  32. ;    This routine returns the name of the currently executing command
  33. ;    procedure.
  34. ;
  35. ;    Call with the address of a string descriptor.
  36. ;    Status is returned in R0
  37. ;
  38. ;-------------------------------------------------------------------------------
  39.  
  40.     .LIBRARY /SYS$LIBRARY:LIB/    ; Executive macro library
  41.     .LINK 'SYS$SYSTEM:SYS.STB'/SELECTIVE_SEARCH
  42.     .LINK "SYS$SYSTEM:DCLDEF.STB"/SELECTIVE_SEARCH
  43.  
  44.     $PCBDEF                ; Process Control Block offsets
  45.     $STSDEF                ; Command Lang defs
  46.     $UAIDEF
  47. ;-------------------------------------------------------------------------------
  48.  
  49.     .PSECT    CODE RD,NOWRT,PIC,EXE,LONG
  50.     .ENTRY    CHECKDIR ^M<r6,r7,r8>        ; Routine entry point
  51.     movzwl    @4(ap),r6
  52.     movl    4(ap),r7
  53.  
  54.         $CMEXEC_S ROUTIN=200$        ;call the retreival code in EXEC mode
  55.         BLBS    R0,5$            ;quit if problem (nopriv)
  56.     BRW    90$
  57. 5$:    MOVL    #SS$_NORMAL,R0
  58. 90$:    RET                ; back to the caller
  59.  
  60. 200$:   .WORD   0            ; Exec entry point
  61.         MOVAL   G^CTL$AG_CLIDATA, R1    ;get address of process's cli area
  62.         MOVAL   @PPD$L_PRC(R1), R1      ;pointer to process permanent data
  63.         MOVAL   @PRC_L_IDFLNK(R1), R1   ;   "    to indirect command file
  64.         MOVAB   @IDF_L_FILENAME(R1), R1 ;   "    to command proc name
  65.         MOVZBl  (R1), r8        ;save length of name
  66.         MOVC5   r8, 1(R1), #^A' ', -    ;copy name--padded with blanks--
  67.                 r6, @4(r7)        ; into passed string
  68.         MOVZWL  #SS$_NORMAL, R0        ; Set success
  69.         RET                ; Return from exec
  70. ;
  71.     .END
  72.  
  73. ----------------------------------------------------------------------------
  74. | Dale O. Miller                          | #   #  ###  #     ####         |
  75. | University of Arkansas at Little Rock   | #   # #   # #     #   #        |
  76. | 2801 S. University                      | #   # ##### #     ####         |
  77. | Little Rock, AR  72204-1099  USA        | #   # #   # #     #  #         |
  78. | (501)569-8714                           |  ###  #   # ##### #   #        |
  79. | DOMILLER@UALR.EDU, DOMILLER@UALR.BITNET | Disclaimer: This does not      |
  80. | 92-20-28 W,34-43-30 N.ICBMNET           | say what I say it doesn't say. |
  81. ----------------------------------------------------------------------------
  82.