Better way to handle temporary data and panels
Thu, 03/11/2021 - 09:36 am
Quite often I have the need to cleanup various waves on experiment close or stop hardware as users are quitting igor with hardware running.
The waves I want to remove will be outdated when the experiment is opened again. Either because they hold some hardware state or because they are only there for caching things and I want to save disk space (we are talking about ~10-100MB per experiment).
Now from my limited understanding of the igor hooks I've come up with something like the following
/// Revert Experiment, or Open Experiment menu items in the File menu.
static Function IgorBeforeNewHook(igorApplicationNameStr)
variable modifiedBefore, modifiedAfter
modifiedBefore = V_flag
modifiedAfter = V_flag
if(!modifiedBefore && modifiedAfter && cmpstr("Untitled", IgorInfo(1)))
static Function IgorQuitHook(igorApplicationNameStr)
Which does the cleanup and resaves the experiment again if required in IgorBeforeNewHook but only removes and stops stuff in IgorQuitHook. I'm skipping over BeforeExperimentSaveHook and IgorStartOrNewHook/etc. to not make it even more difficult to understand.
Now that experiment resaving takes a lot of time and is potentially dangerous as I'm doing it without the users informed consent.
How do you guys solve that problem?