Charles,

I see exactly where your coming from, very nice. This kinda reminds of the old C++ try and catch type error handling. So I get the impression you want to call this function from many different places in your script, its just that the exist function isn't playing ball ?

My suggestion would be to modify the UDF to pass the value of @ERROR as a parameter - instead of just checking it "globally", example:

function catcherror($error, $errortext)
if $error <> 0
messagebox("$errortext",48)
del(c:\temp.bat)
exit
endif
endfunction

Then, for the bulk of your trapping, you can do this:

somecode...
else
catcherror(@ERROR,"Some message")
endif

and for stuff that doesn't trigger @ERROR's, you might force an error through the parm, like this:

if exist ("c:\notes\notes.ini")
$notesini = "c:\notes\notes.ini"
else
catcherror(2,"Could not find your notes.ini file.")*****
endif

Follow me on this one ?

-Shawn