Absent Member.
Absent Member.

[archive] Directory information

[Migrated content. Thread originally posted on 18 September 2008]

I know I've seen it somewhere in the documentation, but I can't seem to find it now.

Isn't there a command to check if a directory exists? I thought it was
one of the C$ commands. Anyone remember?
1 Reply
Absent Member.
Absent Member.

RE: [archive] Directory information

[SIZE=3][FONT=Consolas]     IDENTIFICATION               DIVISION.[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     PROGRAM-ID.                  TEMPLATE.[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     ENVIRONMENT                  DIVISION.[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     CONFIGURATION                SECTION.[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     copy "..\sample\def\acucobol.def".[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     01  pattern       pic x(5) value ".". [/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     01  directory     pic x(20) value ".\ADirectoryThatExist". [/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     01  filename      pic x(128). [/FONT][/SIZE]
[SIZE=3][FONT=Consolas]     01  mydir         usage handle. [/FONT][/SIZE]

[SIZE=3][FONT=Consolas]     MAIN-LOGIC.[/FONT][/SIZE]

[SIZE=3][FONT=Consolas]         perform check-dir[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         move "doesnotexist" to directory[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         perform check-dir[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         stop run.                                             [/FONT][/SIZE]

[SIZE=3][FONT=Consolas]     check-dir.[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         call "C$LIST-DIRECTORY"[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]           using listdir-open, directory, pattern[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         move return-code to mydir[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         if mydir = 0[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]            display directory " does not exist"[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         else[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]            display directory " does exist"[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]            call "C$LIST-DIRECTORY" using listdir-close, mydir[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         end-if[/FONT][/SIZE]
[SIZE=3][FONT=Consolas]         EXIT    PARAGRAPH.[/FONT][/SIZE]
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.