I might be missing something obvious but I can’t figure out how to get a Component (in this case a table) into a script module. I got it working by running a query to SQL to get the data, but the data I need for the script is already in a table. I guess I can go the other way- pull the data with the script and return it to the table with a function call. It seems that there must be a way to manipulate window components from script modules though, not just event scripts, right? What about accessing components on another screen from an event script? This one seems doubtful.
You can access properties from other windows or script modules. The thing to be careful on is that the window may or may not be open. In any case use the use the following script:
window = system.gui.getWindow('Header')
window.getRootContainer().getComponent('Label').text = "Machine 1 Starting"
system.gui.warningBox("The Header window isn't open")You will notice the try block around my code. That way if the window is not open you can handle it cleanly. Hope this helps.
Thanks- that should work. I am only calling the script module function from an expression binding on a table’s data property, so the screen should always be open. If the window is closed, the expression would not run, right?
Is there any function that will return a reference to a window REGARDLESS of whether it is open or not??
I want to loop through a list of windows, and do something to certain components in each window.
I do not want to manually open each window in the Designer so that i can run my script. That just seems daft.
I cant seem to find any function that allows this though.
The window object doesn’t even exist until it’s open. So, no. Windows are stored in the project as serialized resources (very custom serialization, I recall). Opening the window deserializes the resource. Saving the window in the designer reserializes it and stores that in the project resources.
You can iterate the project resources I presume, and figure out which ones are windows. I haven’t done that, but there’s some generic hints at that in the SDK docs.