Roll Windows

Hi,
I would like to use a Client Event scripts with a time event to swap windows.
This application is to show production value on a screen so I need to swap between current and best production.
I manage to write a script but my IF/ELSE script is using a variable X that is increment at each call but I don’t know the best way to have a session variable accesible from that script since I need to keep the value of X alive between calls of the event.

my code
if x > 5:
x = 1

if x == 1:
system.nav.swapto(“Windows”+1)
elif == 2:
system.nav.swapto(“Windows”+2)
elif == 3:
system.nav.swapto(“Windows”+3)
elif == 4:
system.nav.swapto(“Windows”+4)
elif == 5:
system.nav.swapto(“Windows”+5)
else:
system.nav.swapto(“Error”)

x = x+1

[quote=“kevinmarchand@bc.com”]Hi,
I would like to use a Client Event scripts with a time event to swap windows.
This application is to show production value on a screen so I need to swap between current and best production.
I manage to write a script but my IF/ELSE script is using a variable X that is increment at each call but I don’t know the best way to have a session variable accesible from that script since I need to keep the value of X alive between calls of the event.

my code
if x > 5:
x = 1

if x == 1:
system.nav.swapto(“Windows”+1)
elif == 2:
system.nav.swapto(“Windows”+2)
elif == 3:
system.nav.swapto(“Windows”+3)
elif == 4:
system.nav.swapto(“Windows”+4)
elif == 5:
system.nav.swapto(“Windows”+5)
else:
system.nav.swapto(“Error”)

x = x+1[/quote]

Make x a gateway db tag, increment that.

tagpath = "Some/Path/%s/Screen" % system.net.getHostName()
x = system.tag.getTagValue(tagpath)

if x > 5:
     if x == 1:
          system.nav.swapto("Windows"+1)
     elif == 2:
          system.nav.swapto("Windows"+2)
     elif == 3:
          system.nav.swapto("Windows"+3)
     elif == 4:
          system.nav.swapto("Windows"+4)
     elif == 5:
          system.nav.swapto("Windows"+5)
     else:
          system.nav.swapto("Error")

     x = x+1

     system.tag.writeToTag(tagpath, x)

I’ve also done it by adjusting the Layer value of each window-- If all windows are open, it’s a much faster swap. The downside is that all windows are open, which is more subscribed items, at a time in the client. With just five windows open though, I wouldn’t think it’d be much of an issue.

Or if you want to use a list, you can create a script that’s very easy to modify the set of rotating windows.

[code]tagpath = “Some/Path/%s/Screen” % system.net.getHostName()
x = system.tag.getTagValue(tagpath)
windows = [“window1name”, “window2name”, “window3name”, “window4name”, “window5name”]

if x >= len(windows):
x = 0

system.nav.swapto(windows[x])
system.tag.writeToTag(tagpath, x+1)[/code]

Not a good idea. That will lock up your windows for five seconds at a time. Neither python’s nor java’s sleep functions are safe on the foreground (gui) thread.

Any ideas on a workaround?

Variation on Bobby’s script updated for v8.

tagpath = “[Client]Some/Path/To/Pointer”

pointer = system.tag.readBlocking([tagpath])[0].value

windows = [“window1name”, “window2name”, “window3name”, “window4name”, “window5name”]

if x >= len(windows):
    x = 0

system.nav.swapto(windows[x])
system.tag.writeBlocking([tagpath], [x+1])