BBS: Inland Empire Archive Date: 10-09-92 (12:48) Number: 305 From: RICHARD DALE Refer#: NONE To: VICTOR YIU Recvd: NO Subj: Error checking in QB Conf: (2) Quik_Bas
VY>capabilities are very limited. The main limitation is that you can
VY>not return to anywhere in your program -- either the statement that
VY>caused the error (what if the user wants to abort?) or the next
I seem to recall that way back in the dark days of BASIC there were
two statements, ERR and ERL, which would return the error number and
error line. You might be able to set up a CASE ERROR routine:
ErrorHandler:
SELECT CASE ERR
CASE 53
RESUME NEXT
CASE 64
PRINT "Bad filename"
CASE 68
PRINT "Device unavailable"
CASE 71
PRINT "Disk not ready"
CASE 76
PRINT "Path not found"
CASE ELSE
PRINT "Error occured:"; ERR; "at line"; ERL
END SELECT
Of course, the ERL would only work if (gasp!) you used line numbers.
Does ERL work with QuickBASIC? I dunno, I have never tried it. But if
it does, you might be able to take the ERL result and compare it to
the line number given by the QB editor. If you wanted to get the
actual error rather than just the error number, you could include this
list of error numbers and their corresponding errors. Note that many of
these errors will be caught by QuickBASIC.
FOR EM=1 TO 51:READ ERNO,ERMS$(ERNO):NEXT
DATA 1,NEXT without FOR,2,Syntax error,3,RETURN without GOSUB,4,Out of data
DATA 5,Illegal function call,6,Overflow,7,Out of memory,8,Undefined line
DATA 9,Subscript out of range,10,Duplicate definition,11,Division by zero
DATA 12,Illegal direct,13,Type mismatch,14,Out of string space
DATA 15,String too long,16,String formula too complex,17,Can't continue
DATA 18,Undefined user function,19,No RESUME,20,RESUME without error
DATA 21,Unprintable error,22,Missing operand,23,Line buffer overflow
DATA 24,Device time-out,25,Device fault,26,FOR without NEXT,27,Out of paper
DATA 29,WHILE without WEND,30,WEND without WHILE,50,Field overflow
DATA 51,Internal error,52,Bad file number,53,File not found
DATA 54,Bad file mode,55,File already open,57,Device I/O error
DATA 58,File already exists,61,Disk full,62,Input past end
DATA 63,Bad record number,64,Bad file name,66,Direct statement in file
DATA 67,Too many files,68,Device unavailable
DATA 69,Communications buffer overflow,70,Disk write protect
DATA 71,Disk not ready,72,Disk media error,74,Rename across disks
DATA 75,Path/file access error,76,Path not found
* 1st 1.01 #567 * 1stReader: Dance with the one that brung ya.
--- FidoPCB v1.2 [ff013/c]
* Origin: Sound Advice - 24 Nodes (816)436-4516 (1:280/333)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET