6 Replies Latest reply on Mar 22, 2013 9:44 AM by philmodjunk

    Pressing a button, what get function do I need?

    obidon

      Title

      Pressing a button, what get function do I need?

      Post

           Evening (Phil)

           I am about to create a hundred plus buttons.  This method is required by the client GUI.

           Each button will trigger the same event, the creation of a fault record.  Each fault has a unique code, this code is being used to name each button object.

           Q1. Is this the right methodology?

           Q2.  How do I set a variable which captures the button name?

           Many Thanks

        • 1. Re: Pressing a button, what get function do I need?
          philmodjunk

               You might consider a table of 100 records, one for each button and use a portal to display these records instead of 100 layout objects set up as buttons. That may make such a large number of buttons more manageable as you can use a scroll bar to scroll the list, filters to pull up subsets of buttons and if the need arises to add/remove/change buttons, a simple data entry operation can do that by editing records in this table. A field in this record can serve as the button lable and can be set up as a button so that clicking it in the portal row performs the script. The same field or a different field in the same record can store the code. The script can then access this field to acquire the code for use in the script.

               If you still decide to go with 100 layout objects as buttons, you can use the script parameter box to pass the needed code to the script. Then Get ( ScriptParameter ) can extract that code from within the script.

          • 2. Re: Pressing a button, what get function do I need?
            obidon

                 Evening phil,

                 The graphic on screen is a sort of jigsaw puzzle image.  By clicking on a paricular piece, you will trigger a script.  The only difference in the script is the $$buttonname, which creates a references to a table of codes to provide a solution.  The portal you refer to will populate as part of the script.

                 Which getfunction do I need to set the $$butonvariable?

                 Thanks

                  

            • 3. Re: Pressing a button, what get function do I need?
              philmodjunk

                   To repeat the last paragraph of my previous post:

                   If you still decide to go with 100 layout objects as buttons, you can use the script parameter box to pass the needed code to the script. Then Get ( ScriptParameter ) can extract that code from within the script.

              • 4. Re: Pressing a button, what get function do I need?
                symbister

                     and you can't use object names as input as a script parameter

                     so for example FM doesn't allow you to click an object named/labelled "FAULT1" and dynamically pass that object name as a script parameter to be used by the script

                     so each button can carry the same script but with different 'hard-coded' script parameters

                • 5. Re: Pressing a button, what get function do I need?
                  obidon

                       Thanks Phil and Symbister,

                       I understood the script parameter.

                       I was hoping that the script parameter could be obtained from the object name.  That would save a shitload of time and help with verification and error tracking.  Alas no.

                        

                       Many Thanks

                  • 6. Re: Pressing a button, what get function do I need?
                    philmodjunk

                         I don't see where it saves any time at all. If it worked, you'd have to type an object name into the Name box on the inspector's position tab for each button. Instead, you type the same exact text into the optional script parameter box. Same typing, different box.