Jump to content

Go to field with script parameter


This topic is 5703 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Use the Get ( ScriptParameter) to control your script and direct it to the appropriate field.

If you're using this as a general purpose button then the script could get quite long with all the fields that need to be catered for, however it's all in one script!

Link to comment
Share on other sites

That is what I did, I have three buttons that go to three different fields, the idea is to use only one script and specify the field name on the button parameter, the problem is on the go to field (or set field) script step where you do not have the possibility to add Get(ScriptParameter), because there is not a calculation condition to choose a field.

Link to comment
Share on other sites

You need an If/End If construct for each field:

If (Get(ScriptParameter) = "field1")

Goto field (field1)

Exit Script

End If

If (Get(ScriptParameter) = "field2")

Goto field (field2)

Exit Script

End If

If (Get(ScriptParameter) = "field3")

Goto field (field3)

Exit Script

End If

You cannot target the field on a direct basis using calculated data. I suppose this makes sure that the script will always run as it cannot possibly address a badly named field from calculated data. Maybe you already made this conclusion.

Sorry if you already have this solution but I thought I'd make it clear for others as well.

Link to comment
Share on other sites

You can make this significantly shorter by using the Else If[] script step:

If (Get(ScriptParameter) = "field1")

Goto field (field1)

Else If (Get(ScriptParameter) = "field2")

Goto field (field2)

Else If (Get(ScriptParameter) = "field3")

Goto field (field3)

End If

Another option is to loop a Go to Next Field[] step, until script parameter matches Get(ActiveFieldName). Neither is very pretty, but..

Link to comment
Share on other sites

But a problem with these apporaches is that they beyond requirering a layout where the field is present, that if the field you need to reach is way down in a long line of tests ...why not make the whole nine yards, and make utility layouts for each field you need to reach.

Although a little tiresom for the developer to establish, will it give the exact same responsetime no matter which field.

Freeze Window

Go to Layout [ Evaluate(Get ( ScriptParameter )) ]

Go to Field [ ] [ Select/perform ]

Go to Next Field

Insert Calculated Result [ $aVar ] [ Select ]

Go to Layout [ original layout ]

Commit Records/Requests [ Skip data entry validation; No dialog ]

Borrowing boldly from this post.

...or checkout my attempt to template it...

--sd

mulitplex.zip

Link to comment
Share on other sites

Using Else If[], is there a noticeable difference in response between the first test returning true, and say the 25th test? Enough to dedicate 25 layouts to this?

(Of course, with proper data structure, this shouldn't be required at all.)

Link to comment
Share on other sites

(Of course, with proper data structure, this shouldn't be required at all.)

Are you taking my lines in the script, as well?? What you need to address as well is the use of repeating and global fields

I could have used you echoing in this thread:

http://www.fmforums.com/forum/showtopic.php?tid/176126/post/203515/hl//#203515

--sd

Link to comment
Share on other sites

This topic is 5703 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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