Microsoft KB Archive/50947

= How to Get Extended Error in QuickBasic Like EXTERR in GWBasic =

Article ID: 50947

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBASIC 4.0b, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBasic 4.5 for MS-DOS, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q50947



SUMMARY
The EXTERR function found in GW-Basic Versions 3.20, 3.22, and 3.23 is not built into QuickBasic Versions 4.00, 4,00b, 4.50, or earlier, but below is a code example calling a DOS interrupt that returns the same information (concerning extended errors in MS-DOS 3.00 and later).

This code example applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50 for MS-DOS, Microsoft Basic Compiler Versions 6.00, and 6.00b for MS-DOS, and to Microsoft Basic PDS Version 7.00 for MS-DOS.



MORE INFORMATION
The EXTERR function found in GW-Basic takes a value of n as an argument and returns a different set of values, depending on the value of n. This return value gives detailed information on the most recent DOS error. For all values of n, EXTERR returns 0 (zero) if there was no previous DOS error, or if the version of DOS is earlier than 3.00.   Value of n        EXTERR(n) Return Value --       --   0                 Extended error code 1                Extended error class 2                Extended error suggested action 3                Extended error locus To find what the error codes returned by EXTERR mean, look up the values in &quot;Advanced MS-DOS Programming, 2nd Edition&quot; by Ray Duncan (published by Microsoft Press, 1988) on Pages 145 and 146. This book also documents the interrupt used below, along with the extended error codes on Pages 453 through 456.

Compile and link with Microsoft QuickBasic 4.00, 4.00b. and 4.50, or with Microsoft Basic Compiler 6.00 and 6.00b as follows: BC Test.bas; LINK Test.bas,,,BRUNxx.Lib+QB.Lib; The &quot;xx&quot; in the library name is for the current version of the product you are using (40, 41, 45, 60, or 61). For Basic compiler 6.00 and 6.00b, use BRUNxxER.LIB (emulation math package) or BRUNxxAR.LIB (alternate math package). For the alternate math library, you must compile with the BC /FPa switch. If you compile with BC /O, link with BCOMxx.LIB instead of BRUNxx.LIB.

Also, if you run this program in the QB.EXE environment, you must load the Quick library QB.QLB as follows: QB /L QB.QLB For Basic PDS 7.00, compile and link as follows: BC Test.bas; LINK Test.bas,,,BRT70ENR.Lib+QBX.Lib; The above example is for the math emulation, near strings, and real mode run-time library. The other posible run-time libraries and their corresponding compiler switches are as follows: Library Name  Compiler Switches     Comments -    BRT70ENR.LIB                         Emulation math, near strings BRT70ANR.LIB       /FPa             Alternate math, near strings BRT70EFR.LIB       /Fs              Emulation math, far strings BRT70AFR.LIB       /FPa /Fs         Alternate math, far strings To use stand-alone libraries, use BCL70xxx.LIB instead of BRT70xxx.LIB, and you must add the compiler switch BC /O.

For the QBX.EXE 7.00 environment, use QBX.QLB as follows: QBX /L QBX.QLB

Code Example
REM $INCLUDE: 'QB.BI' ' For BC.EXE and QBX.EXE in Basic 7.00, use the include file 'QBX.BI'

DIM Inregs AS RegTypeX, Outregs AS RegTypeX CLS INPUT &quot;Enter the filename &quot;; test$ test$ = test$ + CHR$(0) Inregs.ax = &H3D00 Inregs.ds = VARSEG(test$) ' For Basic Compiler 7.00 and QBX.EXE use SSEG(test$) '    instead of VARSEG(test$)

Inregs.dx = SADD(test$) CALL INTERRUPTX(&H21, inregs, outregs) check = outregs.flags AND &H1 IF check = 1 THEN PRINT &quot;The file was not found&quot; Inregs.ax = &H5900 Inregs.bx = inregs.bx AND &HFF CALL INTERRUPTX(&H21, Inregs, Outregs) PRINT &quot;This is the error number&quot;; Outregs.ax ELSE PRINT &quot;Your file was found, no extended error information is needed&quot; END IF END

Additional query words: QuickBas BasicCom

Keywords: KB50947

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.