3 Replies Latest reply on Apr 11, 2012 8:46 PM by Dillik

    Use name of button in script with Get (ActiveLayoutObjectName)



      Use name of button in script with Get (ActiveLayoutObjectName)


      I am trying to use the object-name of a button in a Quickfind script that runs when you press that button (I have about 30 named buttons and trying to avoid entering a different script for each, would rather have one script with button-name as the variable).

      This is a similar problem to dob85y, see previous thread - http://forums.filemaker.com/posts/5bc4154b74

      I have tried using Get (ActiveLayoutObjectName) as a function in the script but that doesn’t work because, as was pointed out in the above thread, clicking a button does not put it in focus on the layout.

      It was suggested to pass “the button's object name as a parameter because you must be using the same script with different buttons.” I could only understand this to mean using Get (ActiveLAyoutObjectName) as a calulated parameter... but this raises the same problem as trying to use it directly in a script. 


        • 1. Re: Use name of button in script with Get (ActiveLayoutObjectName)

          It's a shame Self isn't usable as a button's script parameter.

          Anyway, the standard solution would be if your button bears the text of, say, "Print" (minus the quotes), then you'd want the script parameter calc for that button to also be set as "Print" (with the quotes).  I'm not sure if you're intentionally sidestepping that approach because it involves redundancy which would make for a headache if the button text were to change...?  Assuming you are, what I might try instead would be for the script parameters and the button labels to refer to the same global variables.

          For example, you might have the print button sending a parameter of $$PrintButton, and the text label for the button would be a merge variable of <<$$PrintButton>>.  Your startup script would populate the variable $$PrintButton with your choice of label text (let's say "Print"), and if you later decided you wanted the print button to say "Print It, Yo", you'd just be changing it in one place (your startup script).  Not only would this condense two changes (button text and script parameter) into one change, but you can actually avoid a third change too if your script is comparing the script parameter against $$PrintButton instead of "Print".  Example: the script runs an If calc to check whether Get(ScriptParameter) = $$PrintButton.  That's kinda handy.

          Of course, if you don't especially care about removing that redundancy, just hard-code the parameter into the button.

          • 2. Re: Use name of button in script with Get (ActiveLayoutObjectName)


            I think I understand now that the suggestion, referred to above, meant use the same script for each button but use a different script parameter in each case. This could be done instead of naming each button and trying to call up the object name in the script


            • 3. Re: Use name of button in script with Get (ActiveLayoutObjectName)

              Ah, sorry, I missed that you were trying to use the object name (as in, that thing called "Name" in the inspector) rather than the text label.