Getting a Return Value from an Independent Module
jjweimer
// This is the first procedure file
#pragma IndependentModule=M1
Function ShowMe()
return 5
end
// This is the second procedure file
#pragma IndependentModule=M2
Function GetMe()
if (exists("M1#ShowMe()"))
Execute/Q/Z "M1#ShowMe()"
endif
return 0
end
#pragma IndependentModule=M1
Function ShowMe()
return 5
end
// This is the second procedure file
#pragma IndependentModule=M2
Function GetMe()
if (exists("M1#ShowMe()"))
Execute/Q/Z "M1#ShowMe()"
endif
return 0
end
How can I best access the value "5" in M2 which is to be returned by the Execute/Q/Z call to ShowMe() in M1?
April 22, 2009 at 09:50 pm - Permalink
I was hoping to avoid globals. On a more general note, I was especially interested in cases where the first procedure file is designed by someone else, where the function return is designed as an information value to be queried through the function, and where the function may or may not contain the needed global. I was hoping that Execute would in some way return the function return value in a flag or variable that could be "captured" (try-catch case??).
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
April 23, 2009 at 06:22 am - Permalink
I'm guessing that WM didn't really intend for independent modules to be used in a way, such as this, that is not exactly independent. Short of WM modifying Execute to somehow store returned values (this would be tricky now that Igor can return not only strings and values but wave references and DF references), I don't see how you could do this without a global variable.
If you're trying to have your module interact with one of my projects please post an issue in the queue and we can try to figure out the best way forward.
April 23, 2009 at 08:07 am - Permalink
I had hoped first to see whether something general existed.
I will follow up appropriately.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
April 23, 2009 at 10:07 am - Permalink