Delete a file: Difference between revisions

→‎{{header|COBOL}}: put DELETE FILE first because that's standard statement
m (Update Lang example: Fix spelling of Lang)
imported>Acediast
(→‎{{header|COBOL}}: put DELETE FILE first because that's standard statement)
Line 478:
 
=={{header|COBOL}}==
AlternateCOBOL method2023 ofadded deletinga files using thededicated <code>DELETE FILE</code> statement.
To delete files or directories in COBOL we need to use unofficial extensions. The following are built-in subroutines originally created as part of some of the COBOL products created by Micro Focus.
{{works with|Visual COBOL}}
{{works with|OpenCOBOL}}
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Delete-Files.
 
PROCEDURE DIVISION.
CALL "CBL_DELETE_FILE" USING "input.txt"
CALL "CBL_DELETE_DIR" USING "docs"
CALL "CBL_DELETE_FILE" USING "/input.txt"
CALL "CBL_DELETE_DIR" USING "/docs"
 
GOBACK
.</syntaxhighlight>
 
Alternate method of deleting files using the <code>DELETE FILE</code> statement.
{{works with|Visual COBOL}}
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Delete-Files-2.
 
ENVIRONMENT DIVISION.
Line 508 ⟶ 493:
FD Local-File.
01 Local-Record PIC X.
 
FD Root-File.
01 Root-Record PIC X.
Line 515 ⟶ 499:
DELETE FILE Local-File
DELETE FILE Root-File
GOBACK.
 
END PROGRAM Delete-Files.</syntaxhighlight>
 
To delete files or directoriesHowever, in COBOLsome implementations we need to use unofficial extensions to delete files, or if we want to delete directories. The following are built-in subroutines originally created as part of some of the COBOL products created by Micro Focus.
{{works with|Visual COBOL}}
{{works with|OpenCOBOL}}
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Delete-Files-2.
 
PROCEDURE DIVISION.
CALL "CBL_DELETE_FILE" USING "input.txt"
CALL "CBL_DELETE_DIR" USING "docs"
CALL "CBL_DELETE_FILE" USING "/input.txt"
CALL "CBL_DELETE_DIR" USING "/docs"
 
GOBACK
Anonymous user