Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Help. What am I doing wrong here? I wrote a script that takes a user to a specific layout based on matching text from a specific field:

If field x = "layout 1"

goto "layout 1"

If field x = "layout 2"

goto "layout 2"

If field x = "layout 3"

goto "layout 3"

etc.

The problem I'm having is that I want to add a line in the script that takes a user to a "Home Layout" if the contents of this specific field don't match any of the criteria:

if field x (is not equal) to "layout 1" or "layout 2# or "layout 3" then

goto "layout home"

I'm sure this is a syntax problem but I'm just not getting it.

Posted

This looks like a perfect opportunity to use :

GotoLayout (by field)

Just go to the layout number given by "X" - no need to have a conditional script at all.

Posted

I suggest that you use a script which intelligently tests whether the layout name is valid by using the PatternCount and LayoutNames functions in combination, uses a loop (in conjuntion with a global number field) to locate the correct layout if the layout name in 'field x' is valid, but sends the user to 'Home Layout' if it is not.

The resulting script will look like this:

[color:"green"]Set Field ["gScript.num", ""]

If ["PatternCount (LayoutNames("yourdbname.fp5"), field x) > 0"]

Freeze Window

Loop

Set Field ["gScript.num", "gScript.num + 1"]

Go to Layout ["gScript.num"]

Exit Loop If ("Status(CurrentLayoutName) = field x"]

End Loop

Else

Go To Layout ["Home Layout"

EndIf


This uses the option to Go to Layout "layout number from field..." based on the incremented number in the global field called gScript.num, stopping the loop when the desired layout is reached. The process will take place in a split second.

One major advantage of this approach is that you don't have to hard-code layout names (other than 'Home Layout', that is) into the formula. If layout names are changed or new layouts added, the script will still function correctly, based on whatever it finds in 'field x'.

Posted

The "Else's" were the problem. I was using "End If" at the end of each line instead of Else. That fixed it right up. Thanks for your help.

Carl.

Posted

The timing of this post is perfect. smile.gif The GotoLayout is exactly what I need for an application I started designing last night. I had forgotten about this script step.

Thanks, Mike

This topic is 8138 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
×
×
  • Create New...

Important Information

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