[comp.databases] dbase error level programmining

ugcharle@cs.Buffalo.EDU (Charles Johnson) (07/14/89)

I'm doing modifications to someone elses program and it has the following
section of code that was causing it to "abend"

	:============================================:

	DO CASE
		CASE ERROR() = 5
		@xx,yy Say "record num > # of records"
		on error
		close database
		OTHERWISE
		@xx,yy SAY "error has occured"
		err_msg = message()
		@xx,yy SAY "error was"+err_msg
		close database index
		on error
	RETURN TO MASTER


	:+++++++++++++++++++++++++++++++++++++++++++:
I understand what it is trying to do but I can't find anything about
the message function or the error value. I'm not sure if they are
coming from DOS or something within DBASE.
Any help, ideas, suggestions or pointers to information would be
greatly appreciated

thanks in advance

awd@dbase.UUCP (Alastair Dallas) (07/15/89)

ERROR() and MESSAGE() are dBASE functions.  ERROR() returns the number of
the dBASE error and MESSAGE() returns a character string describing it.
In your code fragment, you specifically check for 5, which is "Record 
out of range" meaning that the program has attempted to read a record
beyond the end of file.  Scanning through the database one record at a
time will usually produce error #4, End of file encountered, rather than
#5, which is produced when some impossible record number is used in,
for example, a GOTO statement.

Hope it helps.

/alastair/