AnsweredAssumed Answered

"Back" Style navigation button, using scripts and global variables. [UPDATED]

Question asked by digitalemu on Mar 13, 2013
Latest reply on Mar 14, 2013 by philmodjunk

Title

"Back" Style navigation button, using scripts and global variables. [UPDATED]

Post

     Hi guys. 

     First of all, this is currently a Work In Progress, however after much working, I feel I have come up with a working solution. 

     I've seen this pop up a couple of times, and there seems to be a bunch of mixed ways of doing this... so I thought I'd share the solution that I'm working on and get some views on it. 

     I will update this as I progress through it. 

     As said above, this solution relies on global variables and scripts, rather than local or global fields. 

     This system should allow as many "steps" as you require. 
     For the purposes of this demonstration, I've limited the steps to 5. 

     The global Variables used are : 

$$back               (number 1 through to whatever) 
$$backstep       (number 1 through to whatever) 
     and
$$backused       (1 or 0)

     The $$back variable is created and modified using an Entry Script as each layout opens and relies on whether the $$backused variable is 1 or 0

     The $$backstep variable is created and modified each time a "Back Button" is used. 

     The $$backused variable is modified when a "Back Button" is clicked. 

     There are 4 Scripts used in this process : 

 "Navigation" 
     "Step Back"
     "Step Foward"

     and
"Clear All"

     The "Navigation" Script

     Is for the $$back variable, and is run at the opening of each layout and is set out as follows : 

IF [$$backused ≠ 1]    #Checks to see if the user has come to this layout using the back button or not
Set Variable [$$backstep; Value:0 ]  #If the user has not used a back button to get here, the global variable is set to 0
Set Variable [$$back5; Value:$$back4]
Set Variable [$$back4; Value:$$back3]
Set Variable [$$back3; Value:$$back2]  #These steps rotate each layout as you visit it, placing them in order. 
Set Variable [$$back2; Value:$$back1]
Set Variable [$$back1; Value:Get(LayoutName)]
     Else
     Set Variable[$$backused; Value:0]  
# Resets this value to free up normal navigation tracking
End If

     The "Step Back" script

     Is for stepping foward through the pages is run at the click of a "Foward" button and is set out as follows :

Set Variable [$$backstep; Value:$$backstep+1] #Sets the first backstep value as 1. 
Set Variable [$$backused; Value:1] #Tells the next layout opening script that it's coming from a "back" button. 
IF [$$backstep=5]
>Show Custom Dialog ["Maximum steps reached"] #Tells the user then can go no further back
>Exit Script []
End If
If[$$backstep=1]
     >Set Variable [$$back ; Get(LayoutName)] 
#Sets the original layout (used for Foward steps)
>Go To Layout [$$back2]
Else If [$$backstep=2]
>Go To Layout [$$back3]
Else If [$$backstep=3]
>Go To Layout [$$back4]
Else If [$$backstep=4]
>Go To Layout [$$back5]
End If

     The "Step Foward" script:

     Is for stepping foward through the pages is run at the click of a "Foward" button and is set out as follows : 

Set Variable [$$backused; Value:1] #Tells the next layout opening script that it's coming from a "back" button. 
IF [$$backstep=0]
     >Show Custom Dialog ["You are already at the first layout"] 
#Tells the user then can go no further foward
Elsef[$$backstep=1]
     >Go To Layout [$$back ]

>Set Variable[$$backstep; Value:$$backstep-1] # Sets this value back by one, so that the "Back" buttons will still work
Else If [$$backstep=2]  #Chooses the step to go back to
>Go To Layout [$$back2]
>Set Variable[$$backstep; Value:$$backstep-1]
Else If [$$backstep=3]  
>Go To Layout [$$back3]
>Set Variable[$$backstep; Value:$$backstep-1]
Else If [$$backstep=4]
>Go To Layout [$$back4]
>Set Variable[$$backstep; Value:$$backstep-1]
Else If [$$backstep=5]
>Go To Layout [$$back5]
>Set Variable[$$backstep; Value:$$backstep-1]
End If

      

     Tooltips for Foward and Back buttons : 

     - FOWARD - 

      

          If($$back2=0; "No navigation History";
          If($$backused ≠ 1;"Back to " & $$back2;
          If($$backstep=1; "Back to " & $$back2;
          If($$backstep=2; "Back to " & $$back3;
          If($$backstep=3; "Back to " & $$back4;
          If($$backstep=4; "Back to " & $$back5;""))))))
      
     - BACK - 

      

          If($$backstep=0;"You cannot go foward";
          If($$backstep=1; "Back to " & $$back1;
          If($$backstep=2; "Back to " & $$back2;
          If($$backstep=3; "Back to " & $$back3;
          If($$backstep=4; "Back to " & $$back4;"")))))
      

      

     The "CLEAR ALL" script:

     I placed on the "Welcome" layout of the database, which clears all global variables used in this 



     I am very open to ideas on this, as I believe I am on to something that could prove very handy in future. 

     As I said earlier, I will keep this post updated on my progress. 

      

      

      

      

Outcomes