11 Replies Latest reply on Apr 5, 2010 12:52 PM by mrvodka

    strange tabbed panel behavior (or expected behavior?)

    johnhorner

      Title

      strange tabbed panel behavior (or expected behavior?)

      Post

      i have set up a tabbed panel with several tabs.  within each tab there is an identical portal that displays related records and allows creation of new related records.  if i am on the default tab, the buttons function as i would expect to create new related records.  the steps of the button script are:

       

      Go to Portal Row [Select; Last]

      Set Field [invoices_INVOICELINEITEMS::ItemCode; "(item code is specific to each button)"

      Go to Field [Select/perform;  invoices_INVOICELINEITEMS::ItemQty]

       

      the problem is that if i am on any of the tabbed panels exept for the default panel, when i click on one of the buttons it jumps to the default tab and then behaves erratically.  sometimes it doesn't appear to do anything except go to the "ItemQty" field in the first protal row, and sometimes it overwrites an existing record's "ItemCode" (usually in the first portal row, and not the last as desired).  is this the expected behavior?  is there a simple way to have it stay on the current tab?  i don't see any script steps like "Go to Tab" for example.  i know i can give the portal object a name and then add a "Go to Object" script step but i was wondering if there is something more "native" or built in to filemaker without resorting to custom naming of the portals on each tabbed panel.  any thoughts/ideas/tips?  thanks.

        • 1. Re: strange tabbed panel behavior (or expected behavior?)
          philmodjunk
            

          Go To Portal Row doesn't have a parameter for specifying to which of your portals you want it to interact with. You have to first select the portal you want then execute this step.

           

          You can give each portal an object name and use go to object to select a specific portal. Just use Go To Object before Go To Portal Row.

          • 2. Re: strange tabbed panel behavior (or expected behavior?)
            johnhorner
               oh well.... i was afraid of that (i have lots of buttons to re-script).  thanks for letting me know.  maybe i will submit a request for the next version that it stays on the current tab for this command...
            • 3. Re: strange tabbed panel behavior (or expected behavior?)
              philmodjunk
                 You may find you can replace your "many scripts" with one script and set up your buttons to pass a parameter to the script that contains the one or two things different (such as the portal's object name and the data you want to put in the portal row.)
              • 4. Re: strange tabbed panel behavior (or expected behavior?)
                johnhorner
                  

                thanks for that idea, it sounds promising.  however, i have not really worked with script parameters before (except to mimick how they were used in other solutions/techniques which i didn't necesarily understand).  i noticed that i can either type in a parameter into the space provided or set up a calculation.  if i type one in, what are the criteria (i.e. can it be a number, or text, or the name of a table, or could i set a variable ("$OneDozen=12"), for example)?  once i have established or passed the parameter to the script, how do i recall it from within the script itself?

                 

                on a slightly different topic, i only recently noticed that in the dialog to setup a button, that there is a popup menu of options for the "current script"  which include, "halt, exit, resume, pause" (mine all seem to be set to pause).  what does this do?

                 

                thanks again for your help!

                • 5. Re: strange tabbed panel behavior (or expected behavior?)
                  philmodjunk
                    

                  Parameters get passed as a text string. If you type information directly in the the parameter box, Filemaker puts quotes around it and treats it as a literal string. If you use the specify option, you then enter a calculation expression that filemaker will evaluate at the time you click the button (or perform the script using the Perform script step which also can be used to pass a parameter.)

                   

                  Either way, you can access the parameter string from with in the performed script using the get function: get (Scriptparameter). If you need to pass more than one item in your parameter screen, you can use text functions to extract each item from the resulting string you get from get (ScriptParameter). Let's say you want to pass "Apple" and the current record's SerialNumberID to a script. You might put this expression in your button's parameter: "Apple " & TableName::IDField  /* note space after Apple */

                   

                  In the script performed by this button click:

                   

                  Leftwords(Get ( ScriptParameter ) ; 1 ) will return "Apple"

                  RightWords(Get ( ScriptParameter ) ; 1 ) will return the contents of the IDField

                   

                  "halt, exit, resume, pause" are options that you almost never have to deal with, but in the rare cases where you do, they're very handy. Some scripts perform a series of actions and then pause for user input. If you click a button while such a script is paused, these options control what happens to your paused script. "Halt" does exactly what Halt Script does inside a script--it halts the current script and any scripts that called it. "Exit" does the same as Exit Script--it exits the current script, but if it was called by some other script that script will continue to execute after your button's actions are completed. "Pause" will leave the paused script paused. "Resume" will trigger the paused script to continue.

                   

                  Three situations where I sometimes pause a script in a manner where these options come into play:

                  I may have a looping script that refreshes the current layout every x seconds--perhaps it performs a find to pull up records created/changed by other users since the previous loop of the script. This script is usually infinite (no exit loop step), but any buttons on this layout use the halt or exit options to terminate the loop.

                   

                  I may have a script that uses new window to pop up a small floating window for user input and pausing the script keeps the user from interacting with the background window until they click a button in the floating window and these buttons either halt or resume the pause script.

                   

                  I may have a special find script that selects a special layout and/or enters some search criteria before pausing so that the user can input additional search criteria. Buttons on this layout may cancel the find and/or do other manipulations where pressing return continues the script in order to perform the find...

                   

                  Historical note: I was real, real excited when I found I could use buttons to pass parameters. In prior versions, I sometimes had as many as 26 scripts (one for each letter of the alphabet) that were different except for that one little detail. They became real nightmares to maintain whenever I had to make matching identical changes to all of them.

                   

                  • 6. Re: strange tabbed panel behavior (or expected behavior?)
                    johnhorner
                       phil, thank you for taking the effort to explain all that so comprehensively.  i didn't get a chance to really read your whole reply carefully, much less tinker around with it, until today and i was able to incorporate some of the tips you suggested.  i especially liked the trick for passing multiple parameters.  i can see now that script parameters will be an integral part of my future!  thanks again... i really appreciate the help!
                    • 7. Re: strange tabbed panel behavior (or expected behavior?)
                      RickWhitelaw
                        

                      To add a mere smidgin to Phil's excellent post, using optional script parameters give your scripts mobility. The same script can be used in many contexts with a different parameter per context. You, for example, could need to sort records in various ways. With a series of buttons across the top of the body of a layout you could use the identical "sort" script for each sort and each button would store a different value (script parameter) which would be passed to the (same) script which would be called within the script as "Get(ScriptParameter)". When I stumbled upon this (Doh!!!) my script making changed forever. There are parallels in many other scripting languages, as I'm now discovering. A little more work at the beginning and a whole lot of time saved later!

                       

                      RW 

                      • 8. Re: strange tabbed panel behavior (or expected behavior?)
                        johnhorner
                          

                        hey rick,  thanks for your post.  i am really looing forward to using these ideas to rework many aspects of my database.  i do indeed have just such a situation where i have 12 buttons across the top of the screen for the months of the year which find and sort those records for me and each one currently with it's own script..... not for long!

                        • 9. Re: strange tabbed panel behavior (or expected behavior?)
                          johnhorner

                          hey phil,

                           

                          i am trying to incorporate your suggesstion of passing multiple script parameters but i am experiencing some difficulty.  i defined the script parameter as follows:

                           

                          TableName1::FieldName1 & " " & TableName1::FieldName2

                           

                          then i set up the script as follows:

                           

                          Leftwords ( Get (ScriptParameter ) ; 1 )

                           

                          this works as expected if the contents of the fields contain a single word.  however, the contents of these fields may have more than one word contained within them.  so what is happening is that the result i am getting if FieldName1 contains "Main Number", is the word "Main".  so rather than giving me the leftwords of the script parameter, it is giving me the leftwords of the referenced fields.  is there a simple way to correct this?

                           

                          thanks!

                          • 10. Re: strange tabbed panel behavior (or expected behavior?)
                            philmodjunk

                            I'm finding the list function to be a convenient way to pass complex data as a single parameter.

                             

                            List ( table::field1 ; table::field 2; table::Field 3 )

                             

                            Then you have functions such as LeftValues, MiddleValues, Filtervalues and RightValues that you can use to extract data from this list of parameter values. Just be aware that left/middle/right values functions return the values as a list with a return at the end so sometimes you have to strip off the extra return character before comparing it to another value.

                             

                            In other words:

                             

                            Subsitute  ( Leftvalues ( apple¶Strawberry ; 1 ) ; ¶ ; "" ) = "apple"

                             

                            Where

                            Leftvalues ( apple¶Strawberry ; 1 )  = "apple¶"

                            • 11. Re: strange tabbed panel behavior (or expected behavior?)
                              mrvodka

                               


                              PhilModJunk wrote:

                               

                              Just be aware that left/middle/right values functions return the values as a list with a return at the end so sometimes you have to strip off the extra return character before comparing it to another value.

                               

                              In other words:

                               

                              Subsitute  ( Leftvalues ( apple¶Strawberry ; 1 ) ; ¶ ; "" ) = "apple"

                               

                              Where

                              Leftvalues ( apple¶Strawberry ; 1 )  = "apple¶"


                              or just use GetValue ( )