I had some working code in an action script initiated when an operator clicked on a button that not only opened a window, but updated a table of window names that had previously been opened to enable forward/back navigation through the queue. I’m trying to convert it to a global script (app.PageLink.PageLinkOpen), and I’ve converted the first couple of statements, but now I’m stuck on the table assignment statement. What is the syntax, or do i need to do this differently?
Original action script code:
Open the desired graphic window
fpmi.nav.openWindow(‘Backwash Primary Coalescer A’)
fpmi.nav.closeWindow(‘Page Links’)
The remainder of the code updates the list keeping track of which
windows are open for the forward/backward navigation buttons to use.
Retrieve list of open windows
windowdata = fpmi.gui.getOpenedWindows()
Use this table to store the window names into
table = event.source.parent.getComponent(“WindowList”)
Setup temporary data structure for window names
headers = [“WindowName”]
data = []
for window in windowdata:
Ignore Non-Process related windows
if (window.name != "Page Links" and window.name != "Banner"):
data.append([window.name])
Write temporary data structure into table
table.data = fpmi.db.toDataSet(headers, data)
Update SQL database table
query = “DELETE FROM WindowQueue”
fpmi.db.runUpdateQuery(query)
order = table.getRowsInViewOrder()
row = 0
for row in order:
graphicname = table.data.getValueAt(row, 0)
graphicndx = row + 1
query = “INSERT INTO WindowQueue SET GUIname = ‘%s’, WindowQueue_ndx = ‘%d’” % (graphicname, graphicndx)
fpmi.db.runUpdateQuery(query)
Global Script Code (currently get error at table = event.source.parent.getComponent(“WindowList”). I think it needs to be something like table = event.source.data but I know I’m missing something.
def PageLinkOpen(WinName):
import fpmi
Open the desired graphic window
fpmi.nav.openWindow(WinName)
fpmi.nav.closeWindow(‘Page Links’)
#Retrieve name of SQL table by referencing client tag
winq = fpmi.tag.getTagValue("[]SQLWindowQueue")
The remainder of the code updates the list keeping track of which
windows are open for the forward/backward navigation buttons to use.
Retrieve list of open windows
windowdata = fpmi.gui.getOpenedWindows()
Use this table to store the window names into
table = event.source.parent.getComponent(“WindowList”)
Setup temporary data structure for window names
headers = [“WindowName”]
data = []
for window in windowdata:
Ignore Non-Process related windows
if (window.name != "Page Links" and window.name != "Banner"):
data.append([window.name])
Write temporary data structure into table
table.data = fpmi.db.toDataSet(headers, data)
Update SQL database table
query = “DELETE FROM ‘%s’” % winq
fpmi.db.runUpdateQuery(query)
order = table.getRowsInViewOrder()
row = 0
for row in order:
graphicname = table.data.getValueAt(row, 0)
graphicndx = row + 1
query = “INSERT INTO ‘%s’ SET GUIname = ‘%s’, WindowQueue_ndx = ‘%d’” % (winq, graphicname, graphicndx)
fpmi.db.runUpdateQuery(query)