Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## OS-DELETE statement

> Executes an operating system file or directory delete from within Progress. Can delete one or more files, a directory, or an entire directory branch.

> #### Syntax

>     OS-DELETE
>       { filename | VALUE ( expression ) } ...
>       [ RECURSIVE ]

> ``filename``

> The name of the files or directories to delete. If you specify a directory that is not empty, you must also specify the RECURSIVE option to delete both the files contained within the directory and the directory itself.

> `VALUE ( `expression` )`

> An expression that returns the name of the files or directories to delete. `expression` can contain constants, field names, and variable names.

> `RECURSIVE`

> Instructs OS-DELETE to delete all subdirectories of the directory named in `filename`, as well as the directory itself. Before a directory or subdirectory is deleted, its files are deleted.

> Example

> This procedure opens a dialog box that prompts the user to choose a file to delete, then uses the OS-DELETE statement to delete the file:

> r-os-del.p
>     DEFINE VARIABLE filename AS CHARACTER NO-UNDO.
>     DEFINE VARIABLE OKpressed AS LOGICAL INITIAL TRUE.

>     Main:
>     REPEAT:
>       SYSTEM-DIALOG GET-FILE filename
>         TITLE     "Choose File to Delete"
>         MUST-EXIST
>         USE-FILENAME
>         UPDATE OKpressed.

>       IF OKpressed = FALSE THEN LEAVE Main.
>         ELSE OS-DELETE VALUE(filename).
>     END.

> #### Notes

> - The filenames and directory names must conform to the naming conventions of the underlying operating system.

> - You cannot use wildcard characters to specify files or directories.

> - If OS-DELETE encounters files or directories that are protected against deletes, it skips over them, generates an error code, but continues to delete any unprotected files and subdirectories that are specified. If several such files or directories are encountered, OS-ERROR returns information on the last error only. If a subdirectory cannot be deleted, then the named directory is not deleted.

> - Although an error can occur during execution of this statement, the statement does not generate an error message, raise an error condition, or affect the program’s flow in any way. Check for an execution error by using the OS-ERROR function and evaluating the return.

> #### See also

> OS-ERROR function

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095