SetIgorHook and IndependentModules question/problem
gregorK
I have a problem using
SetIgorHook
in independent modules. I created a procedure which is run after IGOR starts and initializes a SetIgorHook
which is defined in an independent module (IM). After this the hook function works as expected. BUT if I now close the experiment file (after saving it of course) and re-open it the hook function does not work (it does not get called). I have found out that just after the hook function is set using SetIgorHook
the global string S_info
presents in the form "IM#hookFunction;"
(which works), BUT after re-opening the saved file this is changed to "ProcGlobal#IM#hookFunction;"
which does not work any more. Deleting this "full path" and resetting it using just "IM#hookFunction;"
makes the hook function being properly called again.Is this a feature, an IGOR bug, my programming BUG or something else? Can anyone help in debugging this problem?
Thanks!
Gregor
SetIgorHook
operation but calling the IGOR hooks directly instead (likeBeforeExperimentSaveHook
for example). I still believe that there is an issue with usingSetIgorHook
in an independent module though.EDIT: these have to be declared static in the independent module else they do not work (at least
BeforeExperimentSaveHook
was not working without being declared static, while for exampleAfterWindowCreatedHook
was working also being public in the independent module).Cheers,
Gregor
February 18, 2014 at 02:53 am - Permalink
I _think_ this indicates that you are trying to have the IM come back execute a function outside of itself without using the Execute command. Alternatively, it indicates that your syntax call to the IM is wrong from your main (non-IM) procedure. Or perhaps you have found a bug.
Could you post a shorted version of the IM and the main procedure to be tested?
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
February 17, 2014 at 05:22 pm - Permalink
There is also a Notebook with instructions how to check and recreate the, in my opinion, weird (wrong) behavior.
Please check the attached IGOR experiment and try if you also get this behavior.
Thanks!
Gregor
February 18, 2014 at 12:34 am - Permalink
However, the fix requires that compilation of the re-opened experiment succeed well enough to locate the independent module.
You might be better off using a static hook function in the independent module rather than SetIgorHook.
DisplayHelpTopic "Static Hook Functions"
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
February 18, 2014 at 02:24 pm - Permalink
********
OK. Got it.
When you first run, the IM is in no space, not even ProcGlobal. Hence, your first StartHook() call leaves the IM in no space (The Twilight Zone). When you quite and restart, the experiment loads the IM in ProcGlobal space. The IM gets pulled out of The Twilight Zone in to a place to reside. You can see this if, after you open, you try a StartHook() followed by a ShowHookName(). You will get ...
TestIM#ExperimentSaveNotification;ProcGlobal#TestIM#ExperimentSaveNotification;
Now, when you save, the hook runs (again).
I think you have two possible ways out of this. Include a IgorStartorNew hook function that kills and then resets the Before...Save hook function. Alternatively, rename the hook Before...Save hook function call. I am working on the latter.
This may be a bug, or it may be a caveat of how the IM is located at first start. I am still not clear.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
February 18, 2014 at 02:57 pm - Permalink
Cheers,
Gregor
February 18, 2014 at 03:49 pm - Permalink