Progress
Language Reference


OS-ERROR Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns a Progress error code that indicates whether an execution error occurred during the last OS-APPEND, OS-COPY, OS-CREATE-DIR, OS-DELETE, OS-RENAME or SAVE CACHE statement.

SYNTAX

OS-ERROR 

EXAMPLE

The following procedure prompts the user to enter a file to delete, attempts to delete the file, and then calls the OS-ERROR function to check for an execution error. If an error occurs, the procedure branches based on the error number and responds accordingly.

r-os-err.p
DEFINE VARIABLE err-status AS INTEGER.
DEFINE VARIABLE filename AS CHARACTER LABEL "Enter a file to delete".

UPDATE filename.
OS-DELETE filename.
err-status = OS-ERROR.

IF err-status <> 0 THEN
  CASE err-status:
  WHEN 1 THEN
    MESSAGE "You are not the owner of this file or directory.".
  WHEN 2 THEN  
    MESSAGE "The file or directory you want to delete does not exist.". 
  OTHERWISE
    DISPLAY "OS Error #" + STRING(OS-ERROR,"99")
      FORMAT "x(13)" WITH FRAME b.
  END CASE. 

NOTES

SEE ALSO

OS-APPEND Statement, OS-COPY Statement, OS-CREATE-DIR Statement, OS-DELETE Statement, OS-RENAME Statement, SAVE CACHE Statement


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