5 Replies Latest reply on Dec 9, 2011 2:52 PM by philmodjunk

    Get ( TriggerKeystroke ) does not return value when used in script parameter expression.

    philmodjunk

      Summary

      Get ( TriggerKeystroke ) does not return value when used in script parameter expression.

      Product

      FileMaker Pro

      Version

      Advanced 11.03

      Operating system version

      Windows 7

      Description of the issue

      Needed to pass single keystroke to generic binary search script as a parameter. So used OnLayoutKeystroke trigger with Get ( TriggerKeystroke ) in optional parameter box to send keystroke to this generic script.

      Script failed and checking in data viewer with debugger enabled reveals that Get ( TriggerKeystroke ) was returning an empty value.

      Workaround

      Used script trigger to perform an intermediary script that was then able to pass the keystroke to the binary search script by putting Get ( TriggerKeyStroke ) in its Perform Script call to the binary search script.

        • 1. Re: Get ( TriggerKeystroke ) does not return value when used in script parameter expression.
          TSGal

          PhilModJunk:

          Thank you for your post, and I apologize for the late reply.

          Could you provide the steps you are taking?

          Get ( TriggerKeystroke ) is similar to Get ( ActiveFieldName ).  That is, if you tab out of the field, it is no longer active and nothing is returned.  It sounds like your script parameter is trying to take the old value.

          In the case of the Data Viewer, once the Get (TriggerKeystroke) has completed there is no value.  If you insert a Pause Script step following the Get (TriggerKeystroke), you will then see the value.

          The script trigger is correct as the keystroke is captured with the trigger.

          TSGal
          FileMaker, Inc.

          • 2. Re: Get ( TriggerKeystroke ) does not return value when used in script parameter expression.
            philmodjunk

            Posts this old no longer float back into Recent Issues when a response is posted and thus I almost missed this one.

            I wanted the current keystroke not an older value.

            The idea is that I have a table that is alpabetically sorted by name and I wanted to scroll the window to expose the first name starting with the letter the user presses from the keyboard. Since I was creating a binary search script that I wanted to be able to use in other cases besides input from a keystroke, I wanted the script to use Get ( ScriptParameter ) to extract the value used in the binary search. Thus, to use this script on the layout in question, I put:

            Get ( TriggerKeystroke )

            in the parameter box of the script trigger.

            Testing reveals that this will return a null value instead of the character of the key that was pressed. If I then write this one line script:

            Perform Script ["Binary search" ; parameter: get ( TriggerKeystroke) ]

            and set the script trigger to perform it, it works.

            • 3. Re: Get ( TriggerKeystroke ) does not return value when used in script parameter expression.
              TSGal

              PhilModJunk:

              Thanks for the additional information.  I have sent everything to Development and Testing for further review.  I will keep you posted.

              TSGal
              FileMaker, Inc.

              • 4. Re: Get ( TriggerKeystroke ) does not return value when used in script parameter expression.
                TSGal

                PhilModJunk:

                Testing informed me this functionality is the way it is designed to run.  The value cannot be passed as a parameter with OnObjectKeystroke or OnLayoutKeystroke.  The script has to be triggered first, so the script being called by OnObjectKeystroke or OnLayoutKeystroke can then use Get (TriggerKeystroke).

                I reviewed the Help section for clarification, and for Get (TriggerKeystroke) it says:

                "Returns a value when running a script triggered by an OnObjectKeystroke or OnLayoutKeystroke script trigger or running a script called from the triggered script; otherwise returns an empty string."

                Although it doesn't really clear up why it can't be passed as a parameter, it appears the OnObjectKeystroke and OnLayoutKeystroke takes precedence for the key being pressed before the keystroke can be evaluated.

                TSGal
                FileMaker, Inc.

                • 5. Re: Get ( TriggerKeystroke ) does not return value when used in script parameter expression.
                  philmodjunk

                  "That's the way it's designed to run?" How odd. The trigger has to fire to perform the script, but the get function can't return a value until the script actually runs? Very counter-intuitive in my book....

                  From what I am not finding in Help, it would appear an upgrade to the documentation on script parameters and how what limitations exist on how they evaluate would be useful...