3 Replies Latest reply on Nov 17, 2015 4:45 PM by dtcgnet

    button text label


      I have about 20 buttons on a layout (and will be adding similar ones).   When any particular button is pressed, I would like it to perform the same script but use the button's text label as a text value in a calculation.  Can that be easily done?  (I could make each button a different variable but doesn't make it simple to add more buttons and use the same script ... each button is a different person's name ... by pressing the button a form letter is created with his/her name, address, telephone ... )  

        • 1. Re: button text label

          If I'm understanding you, you have something like:

          Bob button. Push Bob button and a form letter fills in Bob.

          Bill button. Push Bill button and form letter fills in Bill.


          And so on.


          Create a global field in a brand new table called Globals. Create a field in that table called "g_Name".  Set the field so it has global storage. Set up the field to use a value list with the names you want to use. Add the field to your layout and put a "Create" button next to it. The Create button runs your script, and the parameter that is passed to your script is whatever the user selected in the Global field. One button can be made to run the script for any name that your user adds to that global field.

          • 2. Re: button text label

            interesting solution ... and you have it right ... want a button to say "Bob" it runs the script using "Bob" as a variable, "Charlie" runs "Charlie" ... so any way to have a script use the text label on a button in its script????

            • 3. Re: button text label

              Using individual buttons like that is going to be a nightmare to keep up with. If you look at the paragraph that starts "Create a global field in a brand new table...", you'll have a method that will work forever, for any names in your database. You'll never have to modify it again (if you set up your value list so it uses information from wherever the names come from). One field and one button that grabs the value from that field, and away you go.


              If you want to do it the way you're thinking (and I highly advise against it), then you'd do this:

              1) Create a button called Bob Smith.

              2) Make the button run your script, and where you can select a parameter, you type "Bob Smith".

              3) In your script, you say, "Set Variable $NameToFind = Get ( ScriptParameter )


              You'd have to do that with every button. It's not horrible, but you'll have a lot of buttons when you could have just 1 instead.