Jump to content
Sign in to follow this  
BobWeaver

Status(CurrentButtonName) ???

Recommended Posts

A few people have posted questions to FMforums about how to use multiple buttons to trigger a single script and then have that script take different actions according to which button was clicked.

Currently, there is no Status(CurrentButtonName) function to determine which button triggered the script, but here is another possibility. You can use the following concept to create a dynamic vertical tool bar on your layouts. It's based on the idea of putting buttons in a portal. It's simple. Create a related file with a key field, a button name field and/or a button icon field, other parameter fields, etc. Create a relationship in your main file to the dynamic button file based on MainFile::KeyField = ButtonFile::KeyField. Then, create a portal on the layout in the main file. Insert the button name/icon field from the related file. Create an invisible button over the portal row.

Link the portal button to a script that begins by setting a global field to the key field in the related file. Then the script can perform various actions based on the parameters stored in the dynamic button file.

The key field in the main file can either be a regular text field or a global. The field will have multiple items (one for each button to be displayed) separated by returns, like this:

NewRecord

Share this post


Link to post
Share on other sites

Or you could duplicate your script, making adjustments for each button, and linking them.

I like simple solutions, I do.

Share this post


Link to post
Share on other sites

Depends on what you are trying to do. This method lets you separate your data from your code to a certain extent.

Share this post


Link to post
Share on other sites

You can also insert a StatusCurrent Modifier Key test onto the button and have it branch according to what modifier key is held down when it is clicked.

Old Advance Man

Share this post


Link to post
Share on other sites

I frequently have to deal with this issue. Bob's method seems to be more complicated than necessary and won't work if there are no records in the file. Checking which key is being held down is unavailable in a Kiosk (I think), and requires either a message on a layout or very well trained users. I think the easiest way is with a bunch of 2 line scripts:

SetField(_CurrentButton#, "Button 1")

Perform Script("My Script)

SetField(_CurrentButton#, "Button 2")

Perform Script("My Script")

_CurrentButton# is a global text. For consistency, I always assign the

button the actual name of the button.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.