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

Else If

Featured Replies

What is the equaviliant of doing an Else If in FM.

Most programming Setups you can do a

If

ElseIf

ElseIf

Else

etc. I don't see that.

Thanks

-j

In scripts, its the If, Else, EndIf series. These can be nested, for example:

code:


if(Name = "Fred")

.do freds stuff

Else

.if(Name = "Bill")

..do bills stuff

.Else

..do the don't recognise the name stuff

.EndIf

EndIf

In a calculation the same nesting rules apply, for example:

code:


NameRecognition = if(Name="Fred","HI Fred",if(Name="Bill","Hi Bill","Never heard of you"))

Russ

[ April 21, 2002, 02:00 PM: Message edited by: Russell Baker ]

  • Author

Thanks. That works. Just wish there was a cleaner way. Get's confusing when you're 5, 6, 7, levels deep.

-j

The only thing I can offer you to de-confuse it, is to write it this way in a calculation.

code:


if(Name = "Fred", "Hi Fred",

if(Name = "Bill", "Hi Bill",

if(Name = "Karen", "Hi Karen",

if(Name = "Sam", "Hi Sam",

if(Name = "Mike", "Hi Mike",

if(Name = "Sue", "Hi Sue",

"Never heard of you"))))))

At least that way you can see what your choices are on a separate line, and then have your final choice if no condition is met on the last line followed by all the parenthesis.

Russ

[ April 21, 2002, 06:36 PM: Message edited by: Russell Baker ]

You can also use the Case function, so you don't have to say If every time. It could end up being just as long, though

Ken

Just so people know how. A case is so much cleaner than a multi line IF. And a hell of a lot easier to read when used in a calculation field.

Case (

Name = "Fred", "Hi Fred",

Name = "Bill", "Hi Bill",

Name = "Karen", "Hi Karen",

Name = "Sam", "Hi Sam",

Name = "Mike", "Hi Mike",

Name = "Sue", "Hi Sue",

"Never heard of you"

)

The last line is if none of the above match then use this

Nice explanation, andy. I wish I had you around when I was learning it!

Ken

Ken,

thanks. Always around if you need help with a project. If you get stuck drop me a line.

You can also split a script up if you have many multiple If/Else steps. One way to keep it clean and eliminate some confusion. Also helps to put in multiple pauses initially to make sure that each step occurs correctly.

True, or instead of pauses get filemaker developer 5.5 and never wonder if you left a pause in somewhere.

A frustration when your users get stuck in a pause and cant think why.

Two clarifications:

1. If ( ) requires a default result; with Case ( ) it's optional.

1b. You can't use Case ( ) in a script anyway.

2. Sometimes you don't need Else, you can just use multiple If's without nesting. Only works where the If's are mutually exclusive, or you want more than one to be evaluated, so... doesn't always apply, but where it does, it's less confusing to read. E.g.???

If (Month(Status(CurrentDate)) = 1)

. Perform Script (January)

End If

If (Month(Status(CurrentDate)) = 2)

. Perform Script (February)

End If

etc.

However, you can simulate Case in the script using multiple if's without nesting, and puting ExitScript after every statement (simulating "break")

Using Fitch's example:

If (Month(Status(CurrentDate)) = 1)

. Perform Script (January)

Exit Script

End If

If (Month(Status(CurrentDate)) = 2)

. Perform Script (February)

Exit Script

End If

etc

Dj

Hello again.

Tfitch, youre absolutely right. Except one thing: you can most certainly use a Case function in a script. I use them all the time when inserting calculated results in scripts. They can also be used in IF functions, but doing so seems redundant.

I mentioned the case function as an alternative to scripting multiple IF functions.

Ken

Create an account or sign in to comment

Important Information

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

Account

Navigation

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.