  COBOL System Services Examples? 
 The Question is:
 
I am looking for a way to determine my current default directory from within a
 COBOL application. I can not find a Run Time Library or System Service that
 returns this information. Can you direct me to a tool that is available for
 this purpose?
 
Craig
 
 
 The Answer is :
 
$ show default
  DCOB$:[DCOBOL.TOOLS]
$ cobol showdef
$ link showdef
$ run showdef
[DCOBOL.TOOLS]
DCOB$:[DCOBOL.TOOLS]
DCOB$:[DCOBOL.TOOLS]
/dcob$/dcobol/tools
 
identification division.
program-id. SHOWDEF.
* From COBOL on OpenVMS use $SETDDIR system service and getcwd() C RTL routine
*  $ help system_services $SETDDIR
*  $ help cc/decc run-time_functions getcwd (VAX)
*  $ help cc      run-time_functions getcwd (Alpha)
environment division.
data division.
working-storage section.
01 DEFLEN2 pic 9(4) comp.
01 DEFLEN4 pic 9(9) comp value 80.
01 DEFVAL  pic x(80).
01 DEFSTAT pic 9(9) comp.
procedure division.
0.  call "DECC$CRTL_INIT".
1.  call "SYS$SETDDIR" using by value      0,
                             by reference  DEFLEN2,
                             by descriptor DEFVAL.
    if DEFLEN2 &gt; 0 display DEFVAL(1:DEFLEN2) else display "Def &gt;80 bytes".
2.  call "decc$getcwd" using by reference  DEFVAL,
                             by value      DEFLEN4
                             giving        DEFSTAT.
    if DEFSTAT not = 0 display DEFVAL else display "Def &gt;80 bytes".
3.  call "decc$getcwd" using by reference  DEFVAL,
                             by value      DEFLEN4,
                             by value      1
                             giving        DEFSTAT.
    if DEFSTAT not = 0 display DEFVAL else display "Def &gt;80 bytes".
4.  call "decc$getcwd" using by reference  DEFVAL,
                             by value      DEFLEN4,
                             by value      0
                             giving        DEFSTAT.
    if DEFSTAT not = 0 display DEFVAL else display "Def &gt;80 bytes".
    stop run.
 
 Answer written or last revised on  6-FEB-2003 
