cfahle Posted August 16, 2002 Posted August 16, 2002 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.
Keith M. Davie Posted August 16, 2002 Posted August 16, 2002 Assuming you have put the Else's in your scripts and all the End If's, following the last If try Else go to layout home followed by the end if's. This final Else should not require an If.
IdealData Posted August 16, 2002 Posted August 16, 2002 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.
CobaltSky Posted August 16, 2002 Posted August 16, 2002 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'.
cfahle Posted August 16, 2002 Author Posted August 16, 2002 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.
Mike D. Posted August 16, 2002 Posted August 16, 2002 The timing of this post is perfect. The GotoLayout is exactly what I need for an application I started designing last night. I had forgotten about this script step. Thanks, Mike
Keith M. Davie Posted August 16, 2002 Posted August 16, 2002 Mark, I was intrigued by your response suggesting, "GotoLayout (by field)" From looking at my copies of FMPro 4.0 and 5.0 I gather that this step is new to FMPro 5.5, or possibly 6.0.
Rigsby Posted August 17, 2002 Posted August 17, 2002 I presume he meant: Go To Layout(Layout number from field)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now