>Hmmm... I'm guessing that if you went through all that work, then there isn't a function. :)
>
>Thanks, but that's far more work than simply writing a method to handle the error. The problem was that I wanted to do something like:
>
>ON ERROR gnErrNum = ERROR() AND gcErrMess = MESSAGE()
>
This does not do an assignment, but would assert a logical condition without any assignment, and might cause an error in itself. You could call a procedure and pass the arguments to it, doing the assignment there; I'd recommend creating an error object, perhaps as an adjunct to your app object, rather than passing around globals, which gives you better encapsulation, is open to fewer side-effects, and could easily contain code to deal with some errors in itself, controlling its response by manipulating a few properties of the error object, and providing a convenient point to distinguish between fatal and recoverable error conditions. You could then point the Error moethod of an object to it, either snagging specific errors to process in the form, passing along the parameters received at the Error method to the generic error handler object in other situations, or bypassing it totally when this is appropriate.
You might look at Doug Hennig's error handler offering on his web site for a few ideas.
>Which, of course, doesn't work. I was trying to avoid having to write a seperate method to assign those global variables, so I hoped to be able to just assign gnErrNum and derive the gcErrMess from that.
>
>It wouldn't be so bad if you could put procedures in methods. I just hate adding a method to the form that's only used in one little snippet of code. :)
>
So don't do it! Create your error object, and in the subclass that you used to create the form (you did subclass the base classes as recommended everywhere), direct the Error method to the default app Error object's handler! Now every form based on this subclass will inherit the default behavior unless you alter it further up the ladder. You could just as easily redirect to a procedure in a common file in your search path; as long as the procedure can be found at runtime, it's there.
>
>>The following code is what I have used to create a table of all error codes and messages. My errors table has the fields ErrNum (I) and Descript (200) field
>>#Include FoxPro.h
>>local lcTable
>>lcTable = ""
>>lcTable = getfile("Error Table:DBF")
>>if empty(lcTable)
>> return
>>endif
>>close tables all
>>use (lcTable) excl alias Errors
>>local lnRetVal
>>lnRetVal = MessageBox("Zap table first?", MB_ICONQUESTION + MB_YESNO, "Warning...")
>>if lnRetVal = IDYES
>> zap
>>endif
>>set order to errnum
>>insert into Errors ( ErrNum, Descript ) values ( 1116, "Too many windows open." )
>>on error do SetError
>>for i = 3000 to 5000
>> if i = 1116
>> loop
>> endif
>> error(i)
>>endfor
>>on error
>>return
>>
>>
>>procedure SetError
>>*
>>local array laError[1]
>>local llInsert
>>lnRetVal = aerror(laError)
>>if lnRetVal = 0
>> return
>>endif
>>llInsert = .t.
>>if laError[1,1] = 1941
>> seek 1941
>> if not eof()
>> llInsert = .f.
>> endif
>>endif
>>if llInsert
>> insert into Errors ( errnum, descript ) ;
>> values ( laError[1,1], laError[1,2] )
>>endif
>>return