Passing parameters between open screens

Is it possible to pass parameters (based on some event) from one open screen to another already open screen without using tags? I have main windows that need to pass values to docked windows based on events in the main window. I saw an old post from '09 but the linked page did not exist (got a 404 error). Also it was for the FPMI product, of which I am unfamiliar, but would think it is simply an earlier version of Ignition.

Thanks,
Mike

It absolutely is; use system.gui.getWindow() to get a reference to another window, then drill into wherever you need to change a property; something like:
system.gui.getWindow("Alarm Popup").rootContainer.getComponent("Table").data = someDatasetFromThisWindow

1 Like

Paul beat me to it. I’ll just add that you can also use the system.gui.getOpenedWindowNames() function to get a tuple of all open windows that you can loop through to check and make sure the window is actually open before trying to access/update any properties. That way you can warn the user that the window is not open instead of throwing an error.

-Will

1 Like

What would the script look like if I wanted to pass a value from window1 to a custom property on the Root Contanier of window2, using the visionWindowClosed event handler on window1 to trigger the event?

I actually do this sort of thing a lot in my current Ignition project (granted I use custom functions which utilize this)

The below example code assumes that window 1 has a text field which is where you are pulling your data you want to pass. It also assumes the custom property for window 2 is on the rootContainer.

It should show the basic logic for sending information between screens. The code is extremely basic and won’t check for both windows to be open.

#This passes a text field on screen 1 to custom property for screen 2 when screen 1 is closed
#this code assumes that both windows are currently open
#if either window is not open, this code will not work

window1 = system.gui.getWindow("Window1Name")				#fetch the first window so we can reference
window2 = system.gui.getWindow("Window2Name")				#fetch the second window so we can reference

text = window1.rootContainer.getComponent("TextField1").text	#fetch the needed data from the first window

window2.rootContainer.customProperty = text		#pass the data we got from window 1 to the custom property in window 2

If you need i can adjust the code to include a check for both windows to be open

1 Like

Thanks for the reply Ryan. I have also been successful with this method you mentioned. My explanation was lacking a few details. I have a ‘navigation’ window that is always open within my project and contains a tab strip to control navigation between windows, using the ‘Swap to Window’ navigation mode. Which I understand to close one window an open another. What I was attempting to do on on the visionWindowClosed event of Window1, was to pass a value to a custom property on the navigation window(which is always open) and then use a visionWindowOpen event on Window2 to pull the value stored in the navigation window’s custom property. I was able to pass the value to the custom property without issue on the visionWindowClosed event, but for some reason pulling the value on the visionWindowOpen event doesn’t seem to work. Should this work? Or is there some issue with the timing of the events when swapping pages, as this happens nearly simultaneously? Let me know your thoughts.

When you say doesn’t work, do you mean you get an error or the data is not present/is wrong?

Is there a reason why you can’t transfer the data directly from window 1 to window 2? Is there a specific reason why it has to go to the Navigation window first?

Also, what is opening window 2? Are you pressing a button on window 1 that then swaps to window 2? Or are you typing the data into window 1, then using the navigation window to close window 1 and swap to window 2?

From what you are saying with the data not grabbing when you use the windowOpened event, it sounds like you have something on Window 1 that is closing window 1 and opening window 2. If that’s the case, then you will most likely run into a problem with timing.

If it is set up the way I think it is, the call to open window 2 is occurring before the call to write the data from window 1. So the data will still appear on the Nav window but it wont be there when window 2 opens and tries fetching it. (because the fetch happens before the write)

If the data needs to be present in both the Nav window and window 2, I would suggest passing the data to both at the same time using the windowClosed event on window 1. There is essentially no limit as to how many screens you can pass data to at any one time, they just all have to be open or else you’ll get an error.

No error is created - I am just unable to pass the value from the Nav Window to Window2 on an windowOpen event.

The Nav Window tab strip has (8) tabs corresponding to (8) windows that need the value of ‘text field’ passed back/forth when swapping from window to window. This field is common on all (8) windows. I was thinking it would be less complex to pass it to a single location vs. passing the value to all pages. And this window is always open so I can get around the issue of passing a value to a closed Window.

Is there any way to pass data to a closed window?

No. A closed window simply doesn't exist in memory.

Consider using a client tag as the global string. Bind all of the text fields to the client tag (bidirectionally, I presume). In any context where this string needs to be updated, but any particular window cannot be presumed to be open, use a tag write to the client tag. (Client tags in Vision are basically per-client memory tags.)

Thanks pturmel! That will work.