Handling Invalid hrefnum for Capture History

OK, now even more surprises with CaptureHistory as started here.

In my application, when my experiment is closed and then reopened, a particular state remembers that it should be capturing history, but the hrefnum is invalid. How can I prevent a call to CaptureHistory(hrefnum,1) from putting up a dialog about an invalid hrefnum? Can this be done within a try-catch-endtry block? My other alternative appears to be a hook before closing or at startup of the experiment to set my global to shut off the history capture.

Essentially, I would be wanting the equivalent of a /Z flag on CaptureHistory(...) as is so handy on operations to catch an error flag and handle it internally.
I believe the CaptureHistory feature was intended for short-term use so you are stretching it.

You should be able to use an AfterFileOpenHook function to set your refNum to zero when an experiment is opened. Then test if it is zero before using it.

hrodstein wrote:
I believe the CaptureHistory feature was intended for short-term use so you are stretching it..


Oh ... I wasn't intending to stretch it to break things. I've handled the issue as you suggested with a AfterFileOpenHook() call.

Thanks.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville