# Roll Windows

**URL:** <https://forum.inductiveautomation.com/t/roll-windows/4122>\
**Category:** Ignition\
**Created:** [March 8, 2012, 1:58pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122 "2012-03-08T13:58:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinmarchand](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@kevinmarchand](https://forum.inductiveautomation.com/u/kevinmarchand)\
**Post date:** [March 8, 2012, 1:58pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122/1 "2012-03-08T13:58:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Greg.Buehler](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Greg.Buehler](https://forum.inductiveautomation.com/u/Greg.Buehler)\
**Post date:** [March 8, 2012, 4:13pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122/2 "2012-03-08T16:13:03Z")

</div>

[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.

```auto
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)
```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 8, 2012, 4:42pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122/3 "2012-03-08T16:42:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [March 12, 2012, 9:30pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122/4 "2012-03-12T21:30:31Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 16, 2019, 8:27pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122/6 "2019-08-16T20:27:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AFULLER](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/afuller/32/7931_2.png) [@AFULLER](https://forum.inductiveautomation.com/u/AFULLER)\
**Post date:** [May 7, 2020, 2:55pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122/7 "2020-05-07T14:55:52Z")

</div>

Any ideas on a workaround?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 7, 2020, 3:04pm UTC](https://forum.inductiveautomation.com/t/roll-windows/4122/8 "2020-05-07T15:04:51Z")

</div>

Variation on Bobby’s script updated for v8.

```python
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])

```
