Off switch for active code by "//" in procedure file
viralvector
I usually put "//" to disable a function, and i have to put multiple "//" in front of each line depend on how long the code is.
It would be better if I could disable a/the function(s) by
1. Select multiple lines of the code
2. "right click"
3. Insert "//" in front of each line.
This would be also useful for making note contains multiple lines.
just a thought
function myfunction()
End
#endif
Requires Igor 6.20 though.
I also have defined some keyboard shortcuts for commenting/decommenting. Save the following snippet as keyboard-shortcuts.ipf in "Igor Procedures" and restart Igor.
#pragma IndependentModule=keyboardShortCuts
Menu "Procedure", dynamic, hideable
"-"
"Commentize/8",/Q, Execute/P/Q/Z "DoIgorMenu \"Edit\", \"Commentize\""
"Decommentize/9",/Q, Execute/P/Q/Z "DoIgorMenu \"Edit\",\"Decommentize\""
"Adjust Indentation/7",/Q, Execute/P/Q/Z "DoIgorMenu \"Edit\",\"Adjust Indentation\""
End
Now you can comment/decomment any selection with CTRL+8 and CTRl+9.
January 20, 2014 at 02:48 pm - Permalink
Beautiful! Thanks!
January 20, 2014 at 03:06 pm - Permalink
To temporarily disable a user-defined function, you can also put an x before the first keyword in the declaration. For example:
print 123
End
xThreadsafe Function test2()
print 456
End
I don't believe that this is documented so I wouldn't rely on the current behavior continuing on until the end of time. For code that you ship you should use #if...#endif statements to disable your code. But this saves you some typing when you're developing code and want to quickly disable a function.
January 21, 2014 at 06:10 am - Permalink
Nice hack!
January 21, 2014 at 09:13 am - Permalink
What I said above is almost but not quite correct. If you save an experiment with lines above the first macro or function in the main procedure window, Igor will try to execute them when you open the experiment. That's intended- it allows you to write experiment initialization commands:
DisplayHelpTopic "Experiment Initialization Procedures"
I will also divulge that Igor 7 will have cmd-/ and cmd-\ shortcuts for Commentize and Decommentize (read "Ctrl" for "cmd" if you're on Windows). Now don't go asking when Igor 7 will be available...
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 21, 2014 at 10:07 am - Permalink
I am not going to ask the release date of Igor 7.
But I have another request for Igor 7.
I use Ctrl +M ; Ctrl + J and data browser very often.
Please add a shortcut for "data browser"
Forgive me if I had overlooked.
Thanks in advance.
January 21, 2014 at 12:46 pm - Permalink
You didn't overlook it, and it looks like there will be a shortcut for it in 7.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 21, 2014 at 12:57 pm - Permalink