PreviousNextIndex

OS-ERROR function

Returns, as an INTEGER value, an ABL 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   NO-UNDO. 
DEFINE VARIABLE filename   AS CHARACTER NO-UNDO FORMAT "x(40)" 
  LABEL "Enter a file to delete". 
UPDATE filename. 
OS-DELETE VALUE(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


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex