Load User Procedures from Menu
Hi,
I have a very simple question to ask.
I have a bunch of self-written procedures saved in User Procedures folder. I don't want to use them as global procedures as they are slowing down initialization/startup of Igor and also not all of them are required for a single experiment.
Instead, I am having a global procedures (saved in Igor Procedures folder) which will create a new Menu containing items which should load corresponding procedures from User Procedures folder.
I have tried the following two methods but none of them are working.
Method 1:
"Procedure 1", loadproc(1)
"Procedure 2", loadproc(2)
End
Function loadproc()
Variable indx
if(indx==1)
#include "Procedure 1"
elseif(indx==2)
#include "Procedure 2"
endif
Method 2:
"Procedure 1", #include "Procedure 1"
"Procedure 2", #include "Procedure 2"
End
From the manual, what I understand is #include will only work before starting any function in a procedure and also found working in such a way.
Can someone help me out how to solve this problem?
Thanks a lot in advance.
SS
Hi,
Have you explored the "Procedure Loader" written by Tony?
https://www.wavemetrics.com/node/21127
Andy
June 5, 2022 at 08:17 am - Permalink
There are various solutions to this. Procedure loader is a good one and it is "done" for you.
Most basic is to use your method 2 but call a function (in the same procedure file) which has
Execute/P "COMPILEPROCEDURES "
of a file "YourFileWithIncludes.ipf" located in User Procedures. This YourFileWithIncludes.ipf contains rest of #include lines you need.
June 5, 2022 at 11:38 am - Permalink
Already tried before posting, but Procedure Loader did not worked for me as I am using an older version (6).
However, the solution provided by ilavsky worked for me.
Thanks again :-)
SS
June 5, 2022 at 10:20 pm - Permalink
The problem with your solution is that any command that starts with pound sign ("#") is a compiler directive, not a run-time command. As noted by @ilavsky, the solution is the Execute/P command, which has the power to add compiler directives to the main procedure window, and then trigger a compile.
June 6, 2022 at 09:24 am - Permalink
In reply to The problem with your… by johnweeks
Thanks @johnweeks. I have came across the following in the manual after got the solution from @ilavsky. It was new for me.
DisplayHelpTopic "Operation Queue"
June 7, 2022 at 02:26 am - Permalink
Yes, exactly. That topic describes the "/P" part of Execute/P
June 7, 2022 at 09:17 am - Permalink