Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with Simple "exclusion script"

Featured Replies

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.

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.

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.

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'.

  • Author

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.

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

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.

I presume he meant: Go To Layout(Layout number from field)

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.