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

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

Recommended Posts

Posted

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 ]

Posted

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 ]

Posted

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

Posted

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.

Posted

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.

Posted

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.

Posted

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

Posted

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

This topic is 8244 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.