Hello,
I am working on creating a JMP App for collecting data into a table and visualizing that data in a user friendly way. As a part of that app, I have a MainWin module that is where the user will spend most of their time. Within that MainWin module, there is an UpdateGUI function that is used to refresh the UI (mostly summarized Table Boxes) with data from the embedded data table.
When a user wants to add data, they launch a second module for data entry. Once the data is entered and they press "OK", the data gets added to the main table. I would like closing this module to place a call to the UpdateGUI function in the MainWin module. I don't remember how I had it written, but this used to work when the second module was a modal window. I've now changed the second module to be a Dialog window, and the call to UpdateGUI no longer works.
To fix this, I tried a few things.
The first error was that the UpdateGUI function was unknown to the second module (seems obvious in retrospect), but when I made the name globally available, calling it from the second module meant that all of the references within the function to the MainWin module were also broken..
The second thing I tried was adding a while loop to the MainWin that waits for a variable to be set to 1 and then calling a refresh. This worked technically, but caused some significant slow downs... maybe because I used a Wait() function.
How would you recommend handling this kind of cross module function call?
Thank you!</CODE></P></LINGO-BODY><LINGO-SUB id="lingo-sub-313041" slang="en-US">Re: JMP App Modules and Namespaces</LINGO-SUB><LINGO-BODY id="lingo-body-313041" slang="en-US"><P>Hi <A href="https://community.jmp.com/t5/user/viewprofilepage/user-id/20438" target="_blank">@mringqui</A>,</P>
<P>I think I have a solution for what you're trying to do. Basically, I think you want to scope a reference to the MainWin instance namespace up to the application namespace. To do that, I added the following line in the MainWin script:</P>
<PRE><CODE class=" language-jsl">Application:MainInstance = this module instance;
I built a trivial app to illustrate. MainWin just displays a number. UpdateWin allows you to input a new number that updates the display in MainWin when you hit Close. You can see how I defined things in the Application namespace script to make the Update GUI expression available across all modules.
display_num = 0;
Update GUI = Expr(
Show(MainInstance:Text_Disp << Get Text);
MainInstance:Text_Disp << Set Text(char(display_num));
);
The approach should generalize to what you want to do.
@cwilldenthank you for looking into this!
Adding the reference in the application namespace made the function accessible to the UpdateWin in a much cleaner way than I was doing before, thank you! I will definitely be leveraging this in future situations.
Unfortunately, calling the function from the UpdateWin still rescopes all of the variables in the function to UpdateWin. I think what I've learned is that I need to clean up my namespaces. Probably need a Names Default to Here(1); thrown in there.
I was able to achieve what I wanted by sending a <<CLICK> to the Refresh button I have in the MainWin. This seems to make sure that everything stays scoped correctly.</CLICK>
Thanks again for the help, you have set me in the right direction