# Back button navigation

**URL:** <https://forum.inductiveautomation.com/t/back-button-navigation/5100>\
**Category:** Ignition\
**Created:** [September 5, 2012, 12:16pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100 "2012-09-05T12:16:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [September 5, 2012, 12:16pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/1 "2012-09-05T12:16:17Z")

</div>

Has anyone ever made a reverse navigationlike this before? I would think that using tags to keep track of the recent windows would slow down the project?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [September 5, 2012, 1:33pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/2 "2012-09-05T13:33:47Z")

</div>

almost there…  
I append a string tag and it has this in it:

[u’Setup/Group Setup’, u"[u’Setup/Divert Setup’, u’’]"]

How can I select the second one here?  
my client tag change script is this:

import system  
Recent = system.tag.read("[System]Client/User/CurrentWindow").value  
old = system.tag.read(“LastWindow”).value  
list = [Recent]  
list.append(old)  
system.tag.writeToTag(“LastWindow”, list)  
I’m starting to think I should be writing to a database all these strings of past windows…

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 5, 2012, 5:02pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/3 "2012-09-05T17:02:04Z")

</div>

Yes, you should either be writing these to the database or to a client dataset tag. Let’s say you go down the client dataset tag route. You can create a new client tag that is a dataset called “Recent Windows”. You script will look something like this:`import system
recentWindows = system.tag.read("[Client]Recent Windows").value
old = system.tag.read("LastWindow").value
system.tag.write("[Client]Recent Windows", system.dataset.addRow(recentWindows, [old])`That is assuming the dataset has only one column that is the window path. You can easily get information out of the dataset:`recentWindows = system.tag.read("[Client]Recent Windows").value
firstWindow = recentWindows.getValueAt(0, 0)
secondWindow = recentWindows.getValueAt(1, 0)`

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [September 5, 2012, 6:07pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/4 "2012-09-05T18:07:11Z")

</div>

I am having some difficulty with the code I wrote before your post.  
I chose to try string tags  
… I couldn’t seem to get it to work with client tags though.  
I like the idea of using dataset tags better.  
Somehow I need to implement what you have into what I have here

[code]back button  
system.tag.writeToTag(“ChangeCount”, 0)  
last = system.tag.read(“LastWindow”).value  
if len(last) \> 2:  
place1 = last.find(’ ‘)  
last = last[place1 + 2:]  
place2 = last.find(’ ') # [0,5,10,15]  
Window = last[0:place2]  
if len(Window) \> 0:  
system.nav.swapTo(Window)  
system.nav.centerWindow(Window)  
system.tag.writeToTag(“LastWindow”, str(last))   
system.tag.writeToTag(“ChangeCount”, 1)

client tag change script for current window  
import system  
Recent = newValue.value  
gold = system.tag.read(“ChangeCount”).value  
if gold == 1:  
list = []  
list.append(Recent)  
#if system.tag.exists(‘LastWindow’):  
old = system.tag.read(“LastWindow”).value  
if len(old) \> 200:  
system.tag.writeToTag(“LastWindow”, ‘’)  
else:  
list.append(old)  
sum = ‘’  
for str in list:  
sum = sum + str + ’ ’  
cache = sum  
system.tag.writeToTag(“LastWindow”, cache)[/code]

and this doesnt compile:

`import system
recentWindows = system.tag.read("[Client]Recent Windows").value
old = system.tag.read("[System]Client/User/CurrentWindow").value
system.tag.write("[Client]Recent Windows", system.dataset.addRow(recentWindows, [old])`

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 5, 2012, 6:35pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/5 "2012-09-05T18:35:28Z")

</div>

Rookie mistake, I forgot the last paran:`import system
recentWindows = system.tag.read("[Client]Recent Windows").value
old = system.tag.read("[System]Client/User/CurrentWindow").value
system.tag.write("[Client]Recent Windows", system.dataset.addRow(recentWindows, [old]))`

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 5, 2012, 6:38pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/6 "2012-09-05T18:38:21Z")

</div>

So what’s wrong with using `system.nav.goBack()`?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [September 5, 2012, 6:41pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/7 "2012-09-05T18:41:36Z")

</div>

!!!  
thanks.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [September 5, 2012, 6:42pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/8 "2012-09-05T18:42:48Z")

</div>

I should learn to use ctl+ spacebar more often…

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 5, 2012, 6:43pm UTC](https://forum.inductiveautomation.com/t/back-button-navigation/5100/9 "2012-09-05T18:43:22Z")

</div>

Or read the user manual 🙂 Appendix C lists all the scripting functions.
