• Scripting: Putting the Cursor into a Specific Field

    From Charles H. Sampson@21:1/5 to All on Sun Oct 21 14:20:36 2018
    In a script, how do I remember a field and later put the cursor into
    that field and make it the active field? I've experimented with Go To
    Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to
    say, neither of these leaves the cursor in the field/object, instead
    putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Charlie
    --
    Nobody in this country got rich on his own. You built a factory--good.
    But you moved your goods on roads we all paid for. You hired workers we
    all paid to educate. So keep a big hunk of the money from your factory.
    But take a hunk and pay it forward. Elizabeth Warren (paraphrased)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helpful Harry@21:1/5 to Charles H. Sampson on Mon Oct 22 13:39:11 2018
    On 2018-10-21 21:20:36 +0000, Charles H. Sampson said:

    In a script, how do I remember a field and later put the cursor into
    that field and make it the active field? I've experimented with Go To
    Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to
    say, neither of these leaves the cursor in the field/object, instead
    putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Each new re-worked version of FileMaker Pro just gets messier and
    messier. Even the Script "Workspace" (the stupid name for the Script
    Editor) is unnecessarily over-complicated. :o(

    This function used to be very easy, but now it seems to be somewhat
    more complicated. I managed to get it to work using this technique ...

    1. In Layout Mode, click in each Field on the Layout one at a time
    and give each a unique Object Name in the silly Inspector palette
    (for the sake of ease of use and understanding, it's probably best
    to simply use an Object Name which is the as the Field's name in
    the Define Fields window).

    2. Create a new Global Text Field called g_ActiveField which the Scripts
    can use to store the currently active Field's Object Name (you can
    probably use a Variable if you prefer).

    3. Now you can use two commands in your Scripts:
    - to store the Object Name of the currently active field use
    Set Field [g_ActiveField; Get(ActiveLayoutObjectName)]

    - to go to the Field stored in g_ActiveField
    Go To Object [Object Name: g_ActiveField]

    I tried using Get(ActiveFieldName) and Go To Field, but they didn't
    seem to want to work in my quick tests.

    If you want to set position the cursor within a Field's data (by
    default it appears on the end of any existing data), you might be able
    use the Set Selection command, but that may suffer the same possible
    problems as Go To Field when not hard-coding which Specific Field you
    want to be in.


    Helpful Harry :o)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Howard Schlossberg@21:1/5 to Charles H. Sampson on Sun Oct 21 18:15:27 2018
    On 10/21/2018 2:20 PM, Charles H. Sampson wrote:
    In a script, how do I remember a field and later put the cursor into
    that field and make it the active field? I've experimented with Go To
    Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to
    say, neither of these leaves the cursor in the field/object, instead
    putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Charlie


    How about using get(activelayoutobjectname) to store it to a variable,
    and then Go To Object to go to it later?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charles H. Sampson@21:1/5 to Helpful Harry on Mon Oct 22 17:23:14 2018
    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:

    On 2018-10-21 21:20:36 +0000, Charles H. Sampson said:

    In a script, how do I remember a field and later put the cursor into
    that field and make it the active field? I've experimented with Go To Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to
    say, neither of these leaves the cursor in the field/object, instead putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Each new re-worked version of FileMaker Pro just gets messier and
    messier. Even the Script "Workspace" (the stupid name for the Script
    Editor) is unnecessarily over-complicated. :o(

    This function used to be very easy, but now it seems to be somewhat
    more complicated. I managed to get it to work using this technique ...

    1. In Layout Mode, click in each Field on the Layout one at a time
    and give each a unique Object Name in the silly Inspector palette
    (for the sake of ease of use and understanding, it's probably best
    to simply use an Object Name which is the as the Field's name in
    the Define Fields window).

    2. Create a new Global Text Field called g_ActiveField which the Scripts
    can use to store the currently active Field's Object Name (you can
    probably use a Variable if you prefer).

    3. Now you can use two commands in your Scripts:
    - to store the Object Name of the currently active field use
    Set Field [g_ActiveField; Get(ActiveLayoutObjectName)]

    - to go to the Field stored in g_ActiveField
    Go To Object [Object Name: g_ActiveField]

    I've tried this, using both the global field and the variable, and I
    can't get it to work. Here's what I've discovered: My script is
    triggered by exit the field (the field object). I hoped that this would activate as I tried to exit the field but before the field is actually
    left. That seems to be the case. I begin by capturing three pieces of
    data: the field's name, using both techniques, and the contents of the
    field. Much later I use a custom dialog to display these data and they
    are what they should be.

    I exit the field in question by clicking in another field, including
    another field of a different record. After the script executes the Go To
    Object or Set Field by Name step, that field is where the cursor is
    placed.

    I've tried all four combinations of Set Variable/Set Field and Go To
    Object/Set Field by Name.

    And here's the latest word: I've just discovered that Set Field By Name
    isn't working at all. Instead of setting the field to its previously
    saved initial value, I tried to set it to a different value. The initial
    value is what showed up.

    I tried using Get(ActiveFieldName) and Go To Field, but they didn't
    seem to want to work in my quick tests.

    If you want to set position the cursor within a Field's data (by
    default it appears on the end of any existing data), you might be able
    use the Set Selection command, but that may suffer the same possible
    problems as Go To Field when not hard-coding which Specific Field you
    want to be in.

    Many thanks as usual, Harry, but I'm still striking out.

    Charlie
    --
    Nobody in this country got rich on his own. You built a factory--good.
    But you moved your goods on roads we all paid for. You hired workers we
    all paid to educate. So keep a big hunk of the money from your factory.
    But take a hunk and pay it forward. Elizabeth Warren (paraphrased)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charles H. Sampson@21:1/5 to Howard Schlossberg on Mon Oct 22 17:23:14 2018
    Howard Schlossberg <howard@nospam.fmprosolutions.com> wrote:

    On 10/21/2018 2:20 PM, Charles H. Sampson wrote:
    In a script, how do I remember a field and later put the cursor into
    that field and make it the active field? I've experimented with Go To Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to
    say, neither of these leaves the cursor in the field/object, instead putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    How about using get(activelayoutobjectname) to store it to a variable,
    and then Go To Object to go to it later?

    Thanks, Howard. If you've seen my response to Helpful Harry's
    suggestions, you will have seen that this is one of the things I've
    tried.

    Charlie
    --
    Nobody in this country got rich on his own. You built a factory--good.
    But you moved your goods on roads we all paid for. You hired workers we
    all paid to educate. So keep a big hunk of the money from your factory.
    But take a hunk and pay it forward. Elizabeth Warren (paraphrased)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helpful Harry@21:1/5 to Charles H. Sampson on Tue Oct 23 19:17:00 2018
    On 2018-10-23 00:23:14 +0000, Charles H. Sampson said:
    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:
    On 2018-10-21 21:20:36 +0000, Charles H. Sampson said:

    In a script, how do I remember a field and later put the cursor into
    that field and make it the active field? I've experimented with Go To
    Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to
    say, neither of these leaves the cursor in the field/object, instead
    putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Each new re-worked version of FileMaker Pro just gets messier and
    messier. Even the Script "Workspace" (the stupid name for the Script
    Editor) is unnecessarily over-complicated. :o(

    This function used to be very easy, but now it seems to be somewhat
    more complicated. I managed to get it to work using this technique ...

    1. In Layout Mode, click in each Field on the Layout one at a time
    and give each a unique Object Name in the silly Inspector palette
    (for the sake of ease of use and understanding, it's probably best
    to simply use an Object Name which is the as the Field's name in
    the Define Fields window).

    2. Create a new Global Text Field called g_ActiveField which the Scripts
    can use to store the currently active Field's Object Name (you can
    probably use a Variable if you prefer).

    3. Now you can use two commands in your Scripts:
    - to store the Object Name of the currently active field use
    Set Field [g_ActiveField; Get(ActiveLayoutObjectName)]

    - to go to the Field stored in g_ActiveField
    Go To Object [Object Name: g_ActiveField]

    I've tried this, using both the global field and the variable, and I
    can't get it to work. Here's what I've discovered: My script is
    triggered by exit the field (the field object). I hoped that this would activate as I tried to exit the field but before the field is actually
    left. That seems to be the case. I begin by capturing three pieces of
    data: the field's name, using both techniques, and the contents of the
    field. Much later I use a custom dialog to display these data and they
    are what they should be.

    I exit the field in question by clicking in another field, including
    another field of a different record. After the script executes the Go To Object or Set Field by Name step, that field is where the cursor is
    placed.

    I've tried all four combinations of Set Variable/Set Field and Go To Object/Set Field by Name.

    And here's the latest word: I've just discovered that Set Field By Name
    isn't working at all. Instead of setting the field to its previously
    saved initial value, I tried to set it to a different value. The initial value is what showed up.

    When you run the 'Go To' Script it causes the database to exit the
    second field (even though it doesn't deactivate) causing the 'Exit'
    Script to be run first, which of course changes the data for the Field
    it will return to.

    It's a clumsy approach, but what you can do is capture the Previous
    Field's Object Name separately:

    - Create another Global Text Field (or variable) called
    g_PreviousActiveField
    (You will also need another Field to similarly capture
    the field data)

    - Create a new Script with the command:
    Set Field [g_PreviousActiveField; g_ActiveField]

    - In Layout Mode, set all the necessary Fields to also
    have an OnObjectEnter trigger using the above Script

    - Change the 'Go To' Script to use the g_PreviousActiveField
    Field:
    Go To Object [Object Name: g_PreviousActiveField]


    What now happens is:
    - Exiting a Field triggers the Exit Script, so stores that Field's
    Object Name in the g_ActiveField.

    - If you have clicked in another Field, it will trigger the
    Enter Script, which copies the current contents of g_ActiveField
    to g_PreviousActiveField.

    - When you run the 'Go To' Script, it goes to the correct field
    because it's ignoring the change to g_ActiveField occuring due to
    the 'Go To' Script first triggering the Exit Script from the
    second Field.

    All clear as mud?? :o)


    This works in some quick tests, but there are three problems though.

    1. If you exit the first Field by clicking anywhere that isn't another
    Field (i.e. a blank space on the layout, a button, etc.), then the
    Enter Script won't be run. You might be able to workaround this by
    including a test in the 'Go To' Script, but it would depend on how
    the second problem can be solved ...

    2. You'll need some way to clear the data from both g_ActiveField and
    g_PreviousActiveField.

    3. If you're using a Layout in List View, then you will also need to
    capture the Record Number when exiting the Field and alter the
    'Go To' Script to go back to the original Record as well as the
    original Field - otherwise when you click on another record to exit
    the Field, the 'Go To' will go to the correct Field, but incorrectly
    in the current Record.


    Perhaps it would help if you explain why you're trying to achieve this.
    There might be a better approach to doing what you want.


    Helpful Harry :o)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charles H. Sampson@21:1/5 to Helpful Harry on Fri Oct 26 19:02:11 2018
    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:

    On 2018-10-23 00:23:14 +0000, Charles H. Sampson said:
    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:
    On 2018-10-21 21:20:36 +0000, Charles H. Sampson said:

    In a script, how do I remember a field and later put the cursor into
    that field and make it the active field? I've experimented with Go To
    Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to
    say, neither of these leaves the cursor in the field/object, instead
    putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Each new re-worked version of FileMaker Pro just gets messier and
    messier. Even the Script "Workspace" (the stupid name for the Script
    Editor) is unnecessarily over-complicated. :o(

    This function used to be very easy, but now it seems to be somewhat
    more complicated. I managed to get it to work using this technique ...

    1. In Layout Mode, click in each Field on the Layout one at a time
    and give each a unique Object Name in the silly Inspector palette
    (for the sake of ease of use and understanding, it's probably best
    to simply use an Object Name which is the as the Field's name in
    the Define Fields window).

    2. Create a new Global Text Field called g_ActiveField which the Scripts >> can use to store the currently active Field's Object Name (you can
    probably use a Variable if you prefer).

    3. Now you can use two commands in your Scripts:
    - to store the Object Name of the currently active field use
    Set Field [g_ActiveField; Get(ActiveLayoutObjectName)]

    - to go to the Field stored in g_ActiveField
    Go To Object [Object Name: g_ActiveField]

    I've tried this, using both the global field and the variable, and I
    can't get it to work. Here's what I've discovered: My script is
    triggered by exit the field (the field object). I hoped that this would activate as I tried to exit the field but before the field is actually left. That seems to be the case. I begin by capturing three pieces of
    data: the field's name, using both techniques, and the contents of the field. Much later I use a custom dialog to display these data and they
    are what they should be.

    I exit the field in question by clicking in another field, including another field of a different record. After the script executes the Go To Object or Set Field by Name step, that field is where the cursor is
    placed.

    I've tried all four combinations of Set Variable/Set Field and Go To Object/Set Field by Name.

    And here's the latest word: I've just discovered that Set Field By Name isn't working at all. Instead of setting the field to its previously
    saved initial value, I tried to set it to a different value. The initial value is what showed up.

    When you run the 'Go To' Script it causes the database to exit the
    second field (even though it doesn't deactivate) causing the 'Exit'
    Script to be run first, which of course changes the data for the Field
    it will return to.

    It's a clumsy approach, but what you can do is capture the Previous
    Field's Object Name separately:

    - Create another Global Text Field (or variable) called
    g_PreviousActiveField
    (You will also need another Field to similarly capture
    the field data)

    - Create a new Script with the command:
    Set Field [g_PreviousActiveField; g_ActiveField]

    - In Layout Mode, set all the necessary Fields to also
    have an OnObjectEnter trigger using the above Script

    - Change the 'Go To' Script to use the g_PreviousActiveField
    Field:
    Go To Object [Object Name: g_PreviousActiveField]


    What now happens is:
    - Exiting a Field triggers the Exit Script, so stores that Field's
    Object Name in the g_ActiveField.

    - If you have clicked in another Field, it will trigger the
    Enter Script, which copies the current contents of g_ActiveField
    to g_PreviousActiveField.

    - When you run the 'Go To' Script, it goes to the correct field
    because it's ignoring the change to g_ActiveField occuring due to
    the 'Go To' Script first triggering the Exit Script from the
    second Field.

    All clear as mud?? :o)


    This works in some quick tests, but there are three problems though.

    1. If you exit the first Field by clicking anywhere that isn't another
    Field (i.e. a blank space on the layout, a button, etc.), then the
    Enter Script won't be run. You might be able to workaround this by
    including a test in the 'Go To' Script, but it would depend on how
    the second problem can be solved ...

    2. You'll need some way to clear the data from both g_ActiveField and
    g_PreviousActiveField.

    3. If you're using a Layout in List View, then you will also need to
    capture the Record Number when exiting the Field and alter the
    'Go To' Script to go back to the original Record as well as the
    original Field - otherwise when you click on another record to exit
    the Field, the 'Go To' will go to the correct Field, but incorrectly
    in the current Record.


    Perhaps it would help if you explain why you're trying to achieve this.
    There might be a better approach to doing what you want.

    Thanks again, Harry. It's going to take me a while to digest all this.

    What I'm trying to do: I have a script that validates input that's
    supposed to be money. It catches every error I could think of and
    informs the user, using a custom dialog. At present, the custom dialog
    has only an OK button. After clicking on this button, the user has to
    click in the field again to fix the error(s). I'd like to modify this so
    the custom dialog has Fix and Accept buttons, with clicking on the Fix
    button resulting in the cursor being in the erroneous field.

    One problem with my current script, which I consider better than
    nothing, is that upon exiting the money field, which is just a number
    field to FM, FM displays the erroneous data using its wildly lax
    interpretation of the input. The result is that no particular error is
    obvious, unless the user notices that the value in the field is not what
    he wanted.

    The reason for wanting an Accept button is another story.

    Charlie
    --
    Nobody in this country got rich on his own. You built a factory--good.
    But you moved your goods on roads we all paid for. You hired workers we
    all paid to educate. So keep a big hunk of the money from your factory.
    But take a hunk and pay it forward. Elizabeth Warren (paraphrased)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none@gmail.com@21:1/5 to All on Sat Oct 27 16:38:16 2018
    Perhaps it would help if you explain why you're trying to achieve this.
    There might be a better approach to doing what you want.

    Thanks again, Harry. It's going to take me a while to digest all this.

    What I'm trying to do: I have a script that validates input that's
    supposed to be money. It catches every error I could think of and
    informs the user, using a custom dialog. At present, the custom dialog
    has only an OK button. After clicking on this button, the user has to
    click in the field again to fix the error(s). I'd like to modify this so
    the custom dialog has Fix and Accept buttons, with clicking on the Fix
    button resulting in the cursor being in the erroneous field.

    One problem with my current script, which I consider better than
    nothing, is that upon exiting the money field, which is just a number
    field to FM, FM displays the erroneous data using its wildly lax interpretation of the input. The result is that no particular error is obvious, unless the user notices that the value in the field is not what
    he wanted.

    The reason for wanting an Accept button is another story.

    Charlie


    Have you tried the automatic field validation FMP offers? Make a number
    field. Goto field options. Choose the second tab (I don't know its
    English name). On this tab set the checkmark on to 'Restrict......'
    (again exact name unknown to me in English) Then from the dropdown
    behind the checkmark choose numeric only.
    OR if you want something more complec, choose 'Through calculation'.
    Then set the last checkmark and create your custom warning.
    No scripts, no triggers. Should work????

    keep well, Erik

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helpful Harry@21:1/5 to none@gmail.com on Sun Oct 28 18:13:24 2018
    On 2018-10-27 14:38:16 +0000, none@gmail.com said:

    Perhaps it would help if you explain why you're trying to achieve this.
    There might be a better approach to doing what you want.

    Thanks again, Harry. It's going to take me a while to digest all this.

    What I'm trying to do: I have a script that validates input that's
    supposed to be money. It catches every error I could think of and
    informs the user, using a custom dialog. At present, the custom dialog
    has only an OK button. After clicking on this button, the user has to
    click in the field again to fix the error(s). I'd like to modify this so
    the custom dialog has Fix and Accept buttons, with clicking on the Fix
    button resulting in the cursor being in the erroneous field.

    One problem with my current script, which I consider better than
    nothing, is that upon exiting the money field, which is just a number
    field to FM, FM displays the erroneous data using its wildly lax
    interpretation of the input. The result is that no particular error is
    obvious, unless the user notices that the value in the field is not what
    he wanted.

    The reason for wanting an Accept button is another story.

    Charlie

    Have you tried the automatic field validation FMP offers? Make a number field. Goto field options. Choose the second tab (I don't know its
    English name). On this tab set the checkmark on to 'Restrict......'
    (again exact name unknown to me in English) Then from the dropdown
    behind the checkmark choose numeric only.
    OR if you want something more complec, choose 'Through calculation'.
    Then set the last checkmark and create your custom warning.
    No scripts, no triggers. Should work????

    keep well, Erik

    Probably the main difference is that with the in-built Validation only
    gives you one error messages, while the Scripted method means you can
    have a more precise error message - a different message for each type
    of error.


    Helpful Harry :o)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helpful Harry@21:1/5 to Charles H. Sampson on Sun Oct 28 18:15:24 2018
    On 2018-10-27 02:02:11 +0000, Charles H. Sampson said:

    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:

    On 2018-10-23 00:23:14 +0000, Charles H. Sampson said:
    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:
    On 2018-10-21 21:20:36 +0000, Charles H. Sampson said:

    In a script, how do I remember a field and later put the cursor into >>>>> that field and make it the active field? I've experimented with Go To >>>>> Object and Set Field by Name (in this case setting it to its saved
    initial contents). In spite of what the online documentation seems to >>>>> say, neither of these leaves the cursor in the field/object, instead >>>>> putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Each new re-worked version of FileMaker Pro just gets messier and
    messier. Even the Script "Workspace" (the stupid name for the Script
    Editor) is unnecessarily over-complicated. :o(

    This function used to be very easy, but now it seems to be somewhat
    more complicated. I managed to get it to work using this technique ... >>>>
    1. In Layout Mode, click in each Field on the Layout one at a time
    and give each a unique Object Name in the silly Inspector palette
    (for the sake of ease of use and understanding, it's probably best
    to simply use an Object Name which is the as the Field's name in
    the Define Fields window).

    2. Create a new Global Text Field called g_ActiveField which the Scripts >>>> can use to store the currently active Field's Object Name (you can
    probably use a Variable if you prefer).

    3. Now you can use two commands in your Scripts:
    - to store the Object Name of the currently active field use
    Set Field [g_ActiveField; Get(ActiveLayoutObjectName)]

    - to go to the Field stored in g_ActiveField
    Go To Object [Object Name: g_ActiveField]

    I've tried this, using both the global field and the variable, and I
    can't get it to work. Here's what I've discovered: My script is
    triggered by exit the field (the field object). I hoped that this would
    activate as I tried to exit the field but before the field is actually
    left. That seems to be the case. I begin by capturing three pieces of
    data: the field's name, using both techniques, and the contents of the
    field. Much later I use a custom dialog to display these data and they
    are what they should be.

    I exit the field in question by clicking in another field, including
    another field of a different record. After the script executes the Go To >>> Object or Set Field by Name step, that field is where the cursor is
    placed.

    I've tried all four combinations of Set Variable/Set Field and Go To
    Object/Set Field by Name.

    And here's the latest word: I've just discovered that Set Field By Name
    isn't working at all. Instead of setting the field to its previously
    saved initial value, I tried to set it to a different value. The initial >>> value is what showed up.

    When you run the 'Go To' Script it causes the database to exit the
    second field (even though it doesn't deactivate) causing the 'Exit'
    Script to be run first, which of course changes the data for the Field
    it will return to.

    It's a clumsy approach, but what you can do is capture the Previous
    Field's Object Name separately:

    - Create another Global Text Field (or variable) called
    g_PreviousActiveField
    (You will also need another Field to similarly capture
    the field data)

    - Create a new Script with the command:
    Set Field [g_PreviousActiveField; g_ActiveField]

    - In Layout Mode, set all the necessary Fields to also
    have an OnObjectEnter trigger using the above Script

    - Change the 'Go To' Script to use the g_PreviousActiveField
    Field:
    Go To Object [Object Name: g_PreviousActiveField]


    What now happens is:
    - Exiting a Field triggers the Exit Script, so stores that Field's
    Object Name in the g_ActiveField.

    - If you have clicked in another Field, it will trigger the
    Enter Script, which copies the current contents of g_ActiveField
    to g_PreviousActiveField.

    - When you run the 'Go To' Script, it goes to the correct field
    because it's ignoring the change to g_ActiveField occuring due to
    the 'Go To' Script first triggering the Exit Script from the
    second Field.

    All clear as mud?? :o)


    This works in some quick tests, but there are three problems though.

    1. If you exit the first Field by clicking anywhere that isn't another
    Field (i.e. a blank space on the layout, a button, etc.), then the
    Enter Script won't be run. You might be able to workaround this by
    including a test in the 'Go To' Script, but it would depend on how
    the second problem can be solved ...

    2. You'll need some way to clear the data from both g_ActiveField and
    g_PreviousActiveField.

    3. If you're using a Layout in List View, then you will also need to
    capture the Record Number when exiting the Field and alter the
    'Go To' Script to go back to the original Record as well as the
    original Field - otherwise when you click on another record to exit
    the Field, the 'Go To' will go to the correct Field, but incorrectly
    in the current Record.


    Perhaps it would help if you explain why you're trying to achieve this.
    There might be a better approach to doing what you want.

    Thanks again, Harry. It's going to take me a while to digest all this.

    What I'm trying to do: I have a script that validates input that's
    supposed to be money. It catches every error I could think of and
    informs the user, using a custom dialog. At present, the custom dialog
    has only an OK button. After clicking on this button, the user has to
    click in the field again to fix the error(s). I'd like to modify this so
    the custom dialog has Fix and Accept buttons, with clicking on the Fix
    button resulting in the cursor being in the erroneous field.

    One problem with my current script, which I consider better than
    nothing, is that upon exiting the money field, which is just a number
    field to FM, FM displays the erroneous data using its wildly lax interpretation of the input. The result is that no particular error is obvious, unless the user notices that the value in the field is not what
    he wanted.

    The reason for wanting an Accept button is another story.

    Charlie

    You could highlight the field that has the error, by putting a
    Calculation Container field behind it on the Layout which "lights up"
    when there's an error in the main field's data.

    Should be easier and more noticeable.

    Helpful Harry :o)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charles H. Sampson@21:1/5 to Helpful Harry on Wed Nov 7 20:09:23 2018
    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:

    On 2018-10-27 02:02:11 +0000, Charles H. Sampson said:

    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:

    On 2018-10-23 00:23:14 +0000, Charles H. Sampson said:
    Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:
    On 2018-10-21 21:20:36 +0000, Charles H. Sampson said:

    In a script, how do I remember a field and later put the cursor into >>>>> that field and make it the active field? I've experimented with Go To >>>>> Object and Set Field by Name (in this case setting it to its saved >>>>> initial contents). In spite of what the online documentation seems to >>>>> say, neither of these leaves the cursor in the field/object, instead >>>>> putting it into the next field in tab order.

    Am I misreading? Am I doing something else wrong?

    FMP 16.

    Each new re-worked version of FileMaker Pro just gets messier and
    messier. Even the Script "Workspace" (the stupid name for the Script >>>> Editor) is unnecessarily over-complicated. :o(

    This function used to be very easy, but now it seems to be somewhat
    more complicated. I managed to get it to work using this technique ... >>>>
    1. In Layout Mode, click in each Field on the Layout one at a time
    and give each a unique Object Name in the silly Inspector palette
    (for the sake of ease of use and understanding, it's probably best
    to simply use an Object Name which is the as the Field's name in
    the Define Fields window).

    2. Create a new Global Text Field called g_ActiveField which the Scripts
    can use to store the currently active Field's Object Name (you can
    probably use a Variable if you prefer).

    3. Now you can use two commands in your Scripts:
    - to store the Object Name of the currently active field use
    Set Field [g_ActiveField; Get(ActiveLayoutObjectName)]

    - to go to the Field stored in g_ActiveField
    Go To Object [Object Name: g_ActiveField]

    I've tried this, using both the global field and the variable, and I
    can't get it to work. Here's what I've discovered: My script is
    triggered by exit the field (the field object). I hoped that this would >>> activate as I tried to exit the field but before the field is actually >>> left. That seems to be the case. I begin by capturing three pieces of
    data: the field's name, using both techniques, and the contents of the >>> field. Much later I use a custom dialog to display these data and they >>> are what they should be.

    I exit the field in question by clicking in another field, including
    another field of a different record. After the script executes the Go To >>> Object or Set Field by Name step, that field is where the cursor is
    placed.

    I've tried all four combinations of Set Variable/Set Field and Go To
    Object/Set Field by Name.

    And here's the latest word: I've just discovered that Set Field By Name >>> isn't working at all. Instead of setting the field to its previously
    saved initial value, I tried to set it to a different value. The initial >>> value is what showed up.

    When you run the 'Go To' Script it causes the database to exit the
    second field (even though it doesn't deactivate) causing the 'Exit'
    Script to be run first, which of course changes the data for the Field
    it will return to.

    It's a clumsy approach, but what you can do is capture the Previous
    Field's Object Name separately:

    - Create another Global Text Field (or variable) called
    g_PreviousActiveField
    (You will also need another Field to similarly capture
    the field data)

    - Create a new Script with the command:
    Set Field [g_PreviousActiveField; g_ActiveField]

    - In Layout Mode, set all the necessary Fields to also
    have an OnObjectEnter trigger using the above Script

    - Change the 'Go To' Script to use the g_PreviousActiveField
    Field:
    Go To Object [Object Name: g_PreviousActiveField]


    What now happens is:
    - Exiting a Field triggers the Exit Script, so stores that Field's
    Object Name in the g_ActiveField.

    - If you have clicked in another Field, it will trigger the
    Enter Script, which copies the current contents of g_ActiveField
    to g_PreviousActiveField.

    - When you run the 'Go To' Script, it goes to the correct field
    because it's ignoring the change to g_ActiveField occuring due to
    the 'Go To' Script first triggering the Exit Script from the
    second Field.

    All clear as mud?? :o)


    This works in some quick tests, but there are three problems though.

    1. If you exit the first Field by clicking anywhere that isn't another
    Field (i.e. a blank space on the layout, a button, etc.), then the
    Enter Script won't be run. You might be able to workaround this by
    including a test in the 'Go To' Script, but it would depend on how
    the second problem can be solved ...

    2. You'll need some way to clear the data from both g_ActiveField and
    g_PreviousActiveField.

    3. If you're using a Layout in List View, then you will also need to
    capture the Record Number when exiting the Field and alter the
    'Go To' Script to go back to the original Record as well as the
    original Field - otherwise when you click on another record to exit
    the Field, the 'Go To' will go to the correct Field, but incorrectly
    in the current Record.


    Perhaps it would help if you explain why you're trying to achieve this.
    There might be a better approach to doing what you want.

    Thanks again, Harry. It's going to take me a while to digest all this.

    What I'm trying to do: I have a script that validates input that's
    supposed to be money. It catches every error I could think of and
    informs the user, using a custom dialog. At present, the custom dialog
    has only an OK button. After clicking on this button, the user has to
    click in the field again to fix the error(s). I'd like to modify this so the custom dialog has Fix and Accept buttons, with clicking on the Fix button resulting in the cursor being in the erroneous field.

    One problem with my current script, which I consider better than
    nothing, is that upon exiting the money field, which is just a number
    field to FM, FM displays the erroneous data using its wildly lax interpretation of the input. The result is that no particular error is obvious, unless the user notices that the value in the field is not what
    he wanted.

    The reason for wanting an Accept button is another story.

    Charlie

    You could highlight the field that has the error, by putting a
    Calculation Container field behind it on the Layout which "lights up"
    when there's an error in the main field's data.

    Should be easier and more noticeable.

    That's interesting and might be related to an upcoming question of mine.
    (Stay tuned.) However, in this case I'm pretty sure the user knows which
    field he just put data into. All I want to do is be nice to him by
    putting the cursor in that field when he clicks on the "Fix" button.

    Thanks as always, Harry.

    Charlie
    --
    Nobody in this country got rich on his own. You built a factory--good.
    But you moved your goods on roads we all paid for. You hired workers we
    all paid to educate. So keep a big hunk of the money from your factory.
    But take a hunk and pay it forward. Elizabeth Warren (paraphrased)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charles H. Sampson@21:1/5 to none@gmail.com on Wed Nov 7 19:32:46 2018
    <none@gmail.com> wrote:

    Perhaps it would help if you explain why you're trying to achieve this.
    There might be a better approach to doing what you want.

    Thanks again, Harry. It's going to take me a while to digest all this.

    What I'm trying to do: I have a script that validates input that's
    supposed to be money. It catches every error I could think of and
    informs the user, using a custom dialog. At present, the custom dialog
    has only an OK button. After clicking on this button, the user has to
    click in the field again to fix the error(s). I'd like to modify this so the custom dialog has Fix and Accept buttons, with clicking on the Fix button resulting in the cursor being in the erroneous field.

    One problem with my current script, which I consider better than
    nothing, is that upon exiting the money field, which is just a number
    field to FM, FM displays the erroneous data using its wildly lax interpretation of the input. The result is that no particular error is obvious, unless the user notices that the value in the field is not what
    he wanted.

    The reason for wanting an Accept button is another story.

    Charlie


    Have you tried the automatic field validation FMP offers? Make a number field. Goto field options. Choose the second tab (I don't know its
    English name). On this tab set the checkmark on to 'Restrict......'
    (again exact name unknown to me in English) Then from the dropdown
    behind the checkmark choose numeric only.
    OR if you want something more complec, choose 'Through calculation'.
    Then set the last checkmark and create your custom warning.
    No scripts, no triggers. Should work????

    Thanks, Erik:

    We're talking a lot of personal opinion here so, as they say, YMMV.

    The problem with your first suggestion is that FMP is much too forgiving
    on input to strictly numeric fields. In particular, it just ignores
    commas. IMO, when a user (that's me) inputs 12,34 into a numeric fields,
    that indicates that he has made a mistake. All sorts of fumble-fingers
    could account for that input: He (I) might have meant 12,034 or 12,341.
    To just accept such an input without protest and treat it as 1234.00 is
    a design error to me.

    FMP also happily accepts 1234.5678, since it has no concept of money.

    As to your second suggestion, my script is very long and complex. I'd
    hate to try to translate it into the functional programming that FMP
    uses in its "by calculation" box.

    Charlie
    --
    Nobody in this country got rich on his own. You built a factory--good.
    But you moved your goods on roads we all paid for. You hired workers we
    all paid to educate. So keep a big hunk of the money from your factory.
    But take a hunk and pay it forward. Elizabeth Warren (paraphrased)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)