Initialize Variables for a Procedure
kstrieb
I can start Igor and load my wave.
I can set variables, but when I run the procedure, the variables are reinitialized.
I have played with declaring them Global when I set them, this doesn't help.
How do I send numeric and string variables to the procedure?
I could write a file for Igor to read in, but that seems a little convoluted?
Thanks for any help here.
I don't understand that.
I suggest you send a zipped copy of your project to support@wavemetrics.com so I can see what you are doing and, if necessary, try it myself.
December 2, 2008 at 08:41 pm - Permalink
Assuming you have a funtion named test_function and you want to pass a numeric variabel num_a
and a string str_b
You can just pass over values to a function by having in your procedure window
function test_function(num_a,str_b)<br />
variable num_a<br />
string str_b<br />
//doing s.th with num_a and str_b<br />
<br />
end<br />
you then call that function from the command window by typing
test_function(12,"abc")
this will run the function with num_a being assigned the value 12 and str_b containing the string "abc"
In the above IGOR will insist on the parameters being defined in the very first line of your script.
It will also insist that the parameters are assigned values when you call the function. But there's also the possibility of optional parameters by putting them in brackets in the procedure window.
January 22, 2009 at 07:54 am - Permalink