Re: exception handler
- Posted by irv mullins <irvm at ellijay.com> Aug 24, 2004
- 457 views
irv mullins wrote: > Anyway, as has been mentioned before, the type() routine could be > extended in such a way as to allow handling many errors, simply by > returning to the top of a program block marked by a 'catch' or > 'try' keyword. > > }}} <eucode> > type file(object x) > if x =-1 then > msgbox("Cannot open file") > return FALSE > else return TRUE > end type > > file fn > object fname > > try > puts(1,"Enter a file name here:") > fname = gets(0) > fn = open(fname,"r") > end try > </eucode> {{{ To follow up, I think this could be added without breaking any code. As it stands, if the type() check fails, the program quits. If it succeeds, then the assignment is made and program flow continues. A new keyword, "try", would patch into type()'s failure routine, and cause execution to resume at the top of the "try" loop. If there was no "try" in effect, then the type() check would act just as it does now, either make a valid assignment, or crash. Irv