1 2 3 Previous Next 30 Replies Latest reply on Feb 5, 2010 12:16 PM by k1ngf1sher

    Script used to cycle through layouts

    k1ngf1sher

      Title

      Script used to cycle through layouts

      Post

      Hi all, I'm building a database that has 10 tables (=10 layouts) of data and I would like to know if either of the following can be done:

       

      1. Use a script to cycle through each of the tables (i.e., layouts; in creation order, or any order, for that matter).

       

      OR

       

      2. Create a custom dialog that pops-up that allows me to select a table from the list of tables in the database.

       

      The reason I ask is because I cannot stand having to go to the drop-down menu for layouts each time I want to switch between tables.  I know I can add buttons to each layout, but I would rather not clutter my gui for this purpose.

       

      Thanks,

      K

        • 1. Re: Script used to cycle through layouts
          ninja
            

          A question to round out what you're trying to end up with...

           

          If you don't want buttons on your layout, how do you figure you'll launch the script once it's written?

          • 2. Re: Script used to cycle through layouts
            philmodjunk
              

            Yep, both are possible.

             

            In a script you can use Go To Layout with a "by calculation" option specifying the layout's number. You can store the layout number in a global field or variable and increment the number by adding one just before you use this step to cycle through your layouts.

             

            For such a pop-up, the Show Custom Dialog falls short as you can't specify a value list.

             

            You can set up a value list of layout names and use it with the New Window command to pop up a small floating window where the user can select a layout. Either a button or a script trigger on the pop-up menu can close this window and then switch you to the desired layout. (There's a layout name by calculation option that can reference a global field where your user has selected a layout name.)

            • 3. Re: Script used to cycle through layouts
              philmodjunk
                

              "If you don't want buttons on your layout, how do you figure you'll launch the script once it's written?"

               

              Ninja, I read the original post that he wants one button to pop up the dialog instead of 10 buttons, one for each layout.

               

              You could also just place a global field on your layout that's formatted to list layouts instead of going the custom dialog route. A script trigger on the field can then switch to the specified layout by name.

              • 4. Re: Script used to cycle through layouts
                mrvodka
                  

                Go to layout by calculation with something like: Get ( LayoutNumber ) -1 and Get ( LayoutNumber ) + 1 can cycle you through the layouts.

                 

                You can even use a new window with a layout used to choose other layouts from if you wish.

                 

                 

                *Edit - sorry didnt see prev posts.

                • 5. Re: Script used to cycle through layouts
                  k1ngf1sher
                    

                  Phil, I read a related post that you had responded to and was trying to figure out how to create a value list that included the names of my layouts.  Can you tell me how to do that?  I might be able to figure out the rest after that.

                   

                  To clarify any confusion, I want to be able to run a script that is triggered with a keystroke (I'm keyboard-centric with my Thinkpad Ultranav keyboard!) rather than navigate to a layout using the tiny drop-down menu native to the FM interface.

                   

                  Thanks to all for your help.  I'll report back on what works!

                  K

                  • 6. Re: Script used to cycle through layouts
                    philmodjunk
                      

                    You have two basic options for setting up your layouts.

                     

                    You can simply enter them by hand as a list of custom values.

                     

                    Or you could write a script that steps through all your layouts, creating a new record in a utility table that stores the name of each layout.

                    Run this script everytime you modify your layout names, or add/remove one. Then you'd use a value list set up that specifies the layout names listed in this utility table.

                     

                    @Mr Vodka, please don't apologize! Your post adds a slight variation on mine and thus widens the list of possible methods for our OP to choose from.

                    • 7. Re: Script used to cycle through layouts
                      k1ngf1sher
                         Phil, If I created a custom list with the layout names, do I have to do anything special in order to let FM know that it should be directed to a layout?  I guess I don't understand how to accomplish what you've described...
                      • 8. Re: Script used to cycle through layouts
                        k1ngf1sher
                           Phil, I like the suggestion for a script to run through all my current layouts and population a utility table with the information.  I realize you don't have a lot of time to answer my additional questions, but if you could provide a quick answer then I might be able to wade my way to a solution.
                        • 9. Re: Script used to cycle through layouts
                          philmodjunk
                            

                          You need a script to use the layout name the user selects to switch to that layout:

                           

                          Define a global field: gGoToLayout and place it on your layout formatted as a drop down list or pop-up menu.

                           

                          write a one line script:

                           

                          Go To Layout [YourTableName::gGoToLayout]  // click the specify button and choose "layout name by calculation"

                           

                          If you are using Filemaker 10, you can use either OnObjectExit (drop down list) or OnObjectModify (pop up menu) to perform the above script automatically when the user selects a layout. If you have an older version of filemaker, you'll need to put a button to the right of the field set to perform this script.

                          • 10. Re: Script used to cycle through layouts
                            ninja
                              

                            Adding on to the flying ideas:

                            If the launched script:

                            - pulled up a new window,

                            - entered the field of the dropdown menu of layouts causing the dropdown to expand

                            - allowed you to use the arrow keys (or first letters with autocomplete) to select a layout

                            - then hit the return key to exit the field

                             

                            Then the exit-triggered script ran gotolayout by calculation as described above...(and resized the window if needed on a PC)

                             

                            Or also, could the script simply pause while you made your selection and the return key act as "continue" to maintain a single script?

                             

                            Jus' thinkin' out loud.

                            • 11. Re: Script used to cycle through layouts
                              philmodjunk
                                 Looks to me like all those options would work, but I'd rather just put the field in the header of my layout with a script trigger. It would take up nearly the same amount of space as a button to pop up the window and I wouldn't have to write all that code for popping up a "modal" window.
                              • 12. Re: Script used to cycle through layouts
                                ninja
                                  

                                Agreed, and yours would avoid the window resize.

                                Either way, if the script started with a GoToField step it could be launched with a keycombo instead of a mouse cue.

                                The new window approach allows the existing layout design to remain untouched but does involve window sizing issues.

                                • 13. Re: Script used to cycle through layouts
                                  k1ngf1sher
                                    

                                  Hi Phil, I realize it's been a while since I asked this question, but is there any way you could write the script to do this:

                                   

                                  (from your posting):

                                  Or you could write a script that steps through all your layouts, creating a new record in a utility table that stores the name of each layout.

                                  Run this script everytime you modify your layout names, or add/remove one. Then you'd use a value list set up that specifies the layout names listed in this utility table.

                                   

                                   

                                  I had considered creating a value list with the layout names, but I can't find anywhere in my FM 'bible' or in this forum how to specify a layout name in a list (would I use brackets to indicate it's a layout?).  If you know this answer, I would appreciate learning it.  However, I'm more interested in learning how to write the above script.

                                   

                                  Thanks again for your help,

                                  K

                                   

                                  • 14. Re: Script used to cycle through layouts
                                    philmodjunk
                                      

                                    I got to thinking about that and just remembered there's a design function that returns a list of layout names.

                                     

                                    Make a layout names table with one text field.  Let's call it LayoutNameTbl and call the text field "layoutList".

                                     

                                    Now a one line script can be used with this table:

                                    Go to Layout [LayoutNameTbl (LayoutNameTabl)]

                                    Show All Records

                                    If [ get (foundcount) ≠ 1 /*there should only be one record in this table */]

                                      Delete All Records [no dialog]

                                      New Record / Request

                                    End If

                                    Set Field [LayoutNameTbl::LayoutList; LayoutNames( get ( fileName ) ) ]

                                     

                                    That loads a complete list of the current file's layout names in a single text field with each name separated by return characters.

                                     

                                    Specify a value list to draw its values from this field in this table and you'll have your list.

                                     

                                    Edit note: changed "Delete found count" to Delete all records.

                                    1 2 3 Previous Next