xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DosError()

Sets or retrieves the last DOS error code.

Syntax

DosError( [<nNewErrorCode>] ) --> nOsErrorCode

Arguments

<nNewErrorCode>
This numeric parameter defines the return value for subsequent DosError() calls.

Return

The function returns the last DOS error code as a numeric value.

Description

The DosError() function returns an error code of the Disk Operating System (DOS) that is set when a disk, directory or file operation fails. This leads normally to a runtime error, so that DosError() is usually called within error handling routines to test if a DOS error has occured. DosError() retains its value until a new DOS error occurs, or a new return value is defined explicitely with <nNewErrorCode>. The return value of DosError() is set to zero after each successful DOS operation. The following table gives an overview of some DOS error codes together with their meaning.

Disk Operating System (DOS) error codes
ErrorDescription
1Invalid function number
2File not found
3Path not found
4Too many open files (no handles left)
5Access denied
6Invalid handle
7Memory control blocks destroyed
8Insufficient memory
9Invalid memory block address
10Invalid environment
11Invalid format
12Invalid access code
13Invalid data
15Invalid drive was specified
16Attempt to remove the current directory
17Not same device
18No more files
19Attempt to write on write-protected media
20Unknown unit
21Drive not ready
22Unknown command
23Cyclic redundancy check (CRC) -- part of diskette is bad
24Bad request structure length
25Seek error
26Unknown media type
27Sector not found
28Printer out of paper
29Write fault
30Read fault
31General failure
32Sharing violation
33Lock violation
34Invalid disk change
35FCB unavailable
36Sharing buffer overflow
38Unable to complete the operation
50Network request not supported
51Remote computer not listening
52Duplicate name on network
53Network path not found
54Network busy
55Network device no longer exists
56NETBIOS command limit exceeded
57System error, NETBIOS error
58Incorrect response from network
59Unexpected network error
60Incompatible remote adapter
61Print queue full
62Not enough space for print file
63Print file was cancelled
64Network name was denied
65Access denied
66Network device type incorrect
67Network name not found
68Network name limit exceeded
69NETBIOS session limit exceeded
70Sharing temporarily paused
71Network request not accepted
72Print or disk redirection is paused
80File exists
82Cannot make directory entry
83Fail on INT 24
84Too many redirections
85Duplicate redirection
86Invalid password
87Invalid parameter
88Network data fault
89Function not supported by network
90Required system component not installed

Info

See also:BEGIN SEQUENCE, ErrorBlock(), FError(), HB_OsError(), TRY...CATCH
Category: Error functions
Source:vm\errorapi.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows how to catch a "file not found" error
// using DosError() within a TRY...CATCH error handling structure.

   PROCEDURE Main
      LOCAL oError

      DosError(55)             // sets current DOS error code

      TRY
         ? DosError()          // result: 55

         USE xyz NEW           // create DOS error

      CATCH oError

         IF DosError() == 2
            ? "File not found:", oError:fileName
            QUIT
         ENDIF
      END

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe