6 Replies Latest reply on Jul 11, 2013 11:48 AM by MilutinPetrovic

    Object name and Get() functions

    MilutinPetrovic

      Title

      Object name and Get() functions

      Post

           Hello friends, 

           I have a question regarding a Get(ActiveLayoutObjectName) function. To make the things simple I have included the sample database in the post.

           The problem is the following:

           As You can see from the image below, I have two tables called Form and Table. In the table Form I have Field 1 and Field 2, which are represented in the form as Edit Box named Left and Right.

           I have set the tab order as in the picture and created the simple script that should once the button is clicked to move focus to the field, and then copy the fields name in the field in the table named Table (i know my naming sucks).

           This is where the problem starts, no matter if I click left or right button I get the name of the left field, even tho the order is set correctly! Please help, this is a simple example but is a part of a much more complex script for me!

            

           Here is a sample database for my problem:
           https://www.dropbox.com/s/6trrcviw9qojjpy/Test.fmp12

            

           Thanks,

           M.

        • 1. Re: Object name and Get() functions
          schamblee

               You have a couple of problem. 

               1.  You are using go to next field.  That is what filemaker is doing.   You need to use go to object and the specify the name of the object you want to go to.

               2.  You are using the same script for both buttons with out using a script parameter.  You need to use different scripts or use a script parameter so the script knows which object you want to go to.

          • 2. Re: Object name and Get() functions
            MilutinPetrovic

                 Sorry for the delay in response, I was on vacation! I will answer in reverse order!

                 Here is the thing, it would be easy to use 2 scripts, if it was this small, but like I said, this is just the part of a major project with at least 40 buttons, so it would mean 40 scripts just for this operation, so separate scripts are out of question! Next thing would be to use script parameters, but I am not quite sure what are they, so any help would be mighty appreciated! I am still a bit green in FileMaker programing...

                 For the first answer, I was under impression that even the text fields are considered the "objects" and that setting the tab order would remedy the issue, but I was wrong, is there a way to do anything except naming the "object" in the script, being that I am trying to use the same script in multiple buttons.

                  

            • 3. Re: Object name and Get() functions
              philmodjunk

                   You don't need 40 scripts, just the same script with a different script parameter assigned to each button. Clicking a button does not make it the active object, so get ( ActivelayoutObjectName ) won't return the object name of the button that is clicked, but the object name of the button may be passed as a script parameter to the script.

              • 4. Re: Object name and Get() functions
                MilutinPetrovic

                     But how? :)

                     I tried all sorts of crazy stuff, but I wasnt sucsessful so far! I am not shure I understand that "script parameters" thing. How do You assign it, and which script or calculation read it?

                     Thanks for helping!

                • 5. Re: Object name and Get() functions
                  IT_User

                       When assigning a script to a button there is a "Specify" button when  "Perform Script" has been chosen.  There is the list of scripts to choose from, and at the bottom there should be a place to enter an "Optional script parameter", which if you click the "Edit" button you can have the script parameter be anything.

                       When you want to retrieve the script parameter in a script you will want to use the function Get ( ScriptParameter ).  You can put that into If statements. (Usually, I store into a veriable first, and then use that variable in the if statement and such.)

                       http://www.filemaker.com/12help/html/func_ref2.32.70.html

                  • 6. Re: Object name and Get() functions
                    MilutinPetrovic

                         Well that solved my problem! Thank You friend, I owe You one... :)