6 Replies Latest reply on Feb 8, 2013 9:04 AM by sastickf_1

    Forward and Back buttons for layout navigation

    JoeMan

      Title

      Forward and Back buttons for layout navigation

      Post

      I was reading a post where Phil mentioned there was a way to use a global field/variable to pop 'off' or 'onto' a stack.

      How can I create such an array in FMP 12 Adv?

        • 1. Re: Forward and Back buttons for layout navigation
          philmodjunk

          It works the same in .FP7 files also.

          A "stack" in data structure jargon is a Last In First Out or LIFO list of values. Since in this case, we want to go to the most recent previous layout, then to the most recent after that and so forth with each click of the button, this is a structure that will work for us. "Push" adds a new value to the lsit. "Pop" removes the most recently added value. You can picture a stack of disposable drink cups with a value written on each cup in a dispensor where you can only add and remove cups from the same end of the stack of cups.

          Push:

          Use the OnLayoutExit Script trigger to perform this script:

          If [ Not $$NoPush ]
             Set Variable [$$LayoutStack ; List ( Get ( LayoutName ) ; $$LayoutStack ) ]
          End If

          Pop:

          Set Variable [$$NoPush ; value: True ]
          Go To Layout [ GetValue ( $$LayoutStack ; 1 ) ]
          Set Variable [$$NoPush ; value: False ]
          Set Variable [$$LayoutStack ; RightValues ( $$LayoutStack ; ValueCount ( $$LayoutStack ) - 1 ]

          • 2. Re: Forward and Back buttons for layout navigation
            JoeMan

            Thanks Phil,

            This is what I did so far:

            I created a script named "Push and Pop" and put in all the script steps properly.

            In Manage | Layouts | Script Triggers, I checked OnLayoutExit and added the "Push and Pop" Script.

            I created 2 buttons (left and right), highlighted both buttons and assigned the "Push and Pop" script at the same time. 

            When I hit either button, it highlights, but does nothing.

            I went wrong somewhere. Am I supposed to enter an optional script parameter for it to know which way to go? Am I supposed to seperate the script into "push" and "pop", and if so, which is back and which is forward?

            • 3. Re: Forward and Back buttons for layout navigation
              philmodjunk

              Push is one script and Pop is the second.

              Ony the first three lines, Push, should be performed by the script trigger.

              Your back button then performs "Pop" to go back to the previous layout.

              Note: The $$NoPush variable is used so that no layout name is pushed on the stack when the "pop" trigger trips the OnLayoutExit Trigger when going back to the previous layout.

              • 4. Re: Forward and Back buttons for layout navigation
                JoeMan

                I got the back button to work by entering "True" as a script parameter into the "pop" script.

                When I enter "False" as a script parameter into the same "pop" script assigned to the forward button, it goes back. How do i get the forward button to go forward?

                • 5. Re: Forward and Back buttons for layout navigation
                  philmodjunk

                  I don't understand your post. There are no references to script parameters in either script.

                  A forward button would require a different set of scripts as this method deletes each layout name as it is "popped" off the stack.

                  • 6. Re: Forward and Back buttons for layout navigation
                    sastickf_1

                         Thank you so much for your example PhilModJunk.  I implemented it with some adjustments into my solution & it is working quite well.  I may need to adjust it again to be able to go back to the prior found set (or prior current record) if the stack includes the same layout multiple times but with different found sets.  Have you accomplished this in any of your solutions?  If so, what is the best (simplest) way to remember a found set?