skip to main content

Library Routines : C$CHDIR

C$CHDIR
The C$CHDIR library routine sets or retrieves the current working directory for relative file paths.
When the current working directory is different from the initial one, all the file names are treated as absolute paths, even if no file-prefix or paths have been specified. This rule could cause strange behaviors with some interfaces.
This routine changes the working directory only for files opened by the COBOL program.
Syntax:
 CALL "C$CHDIR" USING directoryName 
Parameters:
Examples:
Example - Getting the current directory and setting a different current directory
working-storage section.
77 dirName pic x(256).
77 errNum  pic 9(9comp-4.
procedure division.
  move spaces to dirName
  call "c$chdir" using dirName errNum
  if errNum = 0
     display message "Current directory is : " dirName
  else
     display message "Error " errNum " when getting current dir"
  end-if.
  move "c:\myapp\mydir1" to dirName
  call "c$chdir" using dirName errNum
  if errNum = 0
     display message "Current directory was set to : " dirName.
  else
     display message "Error " errNum " when setting current dir"
  end-if.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left