Getting a Return Value from an Independent Module

Suppose I have two Independent Modules ...

//  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


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?
andyfaff wrote:
I'm thinking you have to set a global variable in M1#ShowMe()


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
jjweimer wrote:

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??).


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.
aclight wrote:
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.


I had hoped first to see whether something general existed.

I will follow up appropriately.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH