AnsweredAssumed Answered

Implementing a "back" button

Question asked by MichaelVoccola on Jun 3, 2012
Latest reply on Jun 4, 2012 by bill1650


Implementing a "back" button


I have used a script to create a "back" button that will allow the user to navigate back through their layout history. A script trigger is placed on all the layouts:



Set Variable [$$Stack; Value:Get ( LayoutName ) & ¶ & $$Stack]


Each layout has a button on it running the following script:


Set Variable [$Layout; Value:GetValue ( $$Stack ; 2 )]

Set Variable [$$Stack; Value:RightValues ( $$Stack ; ValueCount ( $$Stack ) -2)]


The issue here, is that when a user reaches the bottom of the stack (hits the 'back' button more times than there are values in the stack), the script stops working until the user has navigated to the equivilent number of 'new' layouts, building the stack back up. Example: a user clicks the back button twice after already reaching the end of the stack, the user must now navigate to three more layouts before the script actually begins working again - the stack seems to have a negative value.

Any ideas on how to avoid navigating past the bottom, resulting in a negative stack?

The link below is a sample file containing some layouts and the two scripts.