I wrote this long post and then only at the end noticed that this post is filed under Panorama Classic, not Panorama X. I think it is still a useful post, so I’ll go ahead and post it anyway.
First of all, if error and all other error trapping is well documented on this page.
In Panorama X error trapping does work with formulafill, though I did find a bug just now (more on that in a moment). If I run this code, I get the message “bad”, just as you would hope.
formulafill date("asdf")
if error
message "bad"
endif
The bug is that the message appears twice!! It doesn’t matter how many records are in the database, the first statement in the error block runs twice. While I’m figuring that out, a temporary fix is to add a nop (no operation) statement as the first statement of the error code.
formulafill date("asdf")
if error
nop
message "bad"
endif
The nop will run twice, but it doesn’t do anything, so no harm no foul.
For those of you scoring at home, here’s the issue I just filed.
You want to avoid errors in formulafill!
So now we know how to trap errors in a formulafill (albeit with a temporary workaround), but you really want to avoid this. As soon as an error occurs, the formulafill stops, so the fill operation isn’t completed. If the error occurs on the 5th record out of 1000, the remaining 995 cells will not be filled.
So I would suggest that you make it impossible for an error to occur. The new Panorama X catcherror( function is fantastic for this. This is one of my favorite functions now, I don’t know how I ever managed without it. Here is a revised
formulafill catcherror(today(),date("asdf"))
Of course you probably don’t want to use today() as the default value in case of an error – maybe zeroblank(0). Since the original post was hypothetical, I don’t know what would be appropriate.