dbTalk Databases Forums  

Case or If/Else

comp.databases.filemaker comp.databases.filemaker


Discuss Case or If/Else in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
CRC123
 
Posts: n/a

Default Case or If/Else - 02-07-2007 , 09:51 PM






How do I know when to use the "Case" script steps as opposed to the
"If/Else" script steps?
I have experimented with both and seem to have more success with
"Case" but don't know when each is indicated.


Reply With Quote
  #2  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Case or If/Else - 02-07-2007 , 10:15 PM






Well, there is no Case script step, so I would suggest always using If/Else.

As for functions, I see no reason to EVER use the If() function since
Case() covers all possibilities all the time.


CRC123 wrote:
Quote:
How do I know when to use the "Case" script steps as opposed to the
"If/Else" script steps?
I have experimented with both and seem to have more success with
"Case" but don't know when each is indicated.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
  #3  
Old   
MaximalVariance
 
Posts: n/a

Default Re: Case or If/Else - 02-08-2007 , 07:16 AM



On Feb 7, 11:15 pm, Howard Schlossberg
<how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Quote:
Well, there is no Case script step, so I would suggest always using If/Else.

As for functions, I see no reason to EVER use the If() function since
Case() covers all possibilities all the time.

CRC123 wrote:
How do I know when to use the "Case" script steps as opposed to the
"If/Else" script steps?
I have experimented with both and seem to have more success with
"Case" but don't know when each is indicated.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance
Generally programmaticially speaking, If/Else is generally slower to
compile then CASE or its SWITCH equivalents. WIth that said, I've
never bothered to benchmark the differences in FM let alone mimicking
a caluculation to perform its equivalent script, but i would think
those calculations would have to be slower (unless calcs have some
optimization--i have no idea) as you to still wrap them in a call to
perform script or the ilk. Bit off topic, but does make me wonder
*how* to benchmakr scripts or calcs in FM?



Reply With Quote
  #4  
Old   
Remi-Noel Menegaux
 
Posts: n/a

Default Re: Case or If/Else - 02-08-2007 , 07:45 AM




"MaximalVariance" <StephenTGallagher (AT) gmail (DOT) com> a écrit dans le message de news: > Generally programmaticially speaking, If/Else is generally slower to
Quote:
compile then CASE or its SWITCH equivalents. WIth that said, I've
never bothered to benchmark the differences in FM let alone mimicking
a caluculation to perform its equivalent script, but i would think
those calculations would have to be slower (unless calcs have some
optimization--i have no idea) as you to still wrap them in a call to
perform script or the ilk. Bit off topic, but does make me wonder
*how* to benchmakr scripts or calcs in FM?

I, once had a client with a so complex set of calculations that it took several seconds for the layout (FMP6) to appear. So I transformed that into a set of concatenated scripts - almost exactly the same formulas that the one used in the calculated fields - and I got instantaneously the layout showing. The price to pay though was to hit a button instead of having directly the results. But my guess was that the scripting method was somewhat in the range of 10 times faster than the multi intricate calculations method.
Remi-Noel


Reply With Quote
  #5  
Old   
Bill Marriott
 
Posts: n/a

Default Re: Case or If/Else - 02-08-2007 , 08:40 AM



Some people will recommend that you don't use If() ever again. I still like
If() in the situations where there are two possible results, or a chain of
such results, and Case() when the logic is more like a dial or "radio
button" sort of behavior.

For example, I find:

If(a>b; Result1; If(c=d; Result2; Result3))

quicker/easier to understand than

Case(a>b; Result1; c=d; Result2; Result3)

Even though both have the same result.

However, Case() is the clearly better choice for:

Case(
a=1; Result1;
a=2; Result2;
a=3; Result3;
a=4; Result4;
a=5; Result5;
Result6
)

Having said that, Case() clearly is capable of doing everything If() can do.
So, if that is what you're comfortable with, go for it.


"CRC123" <wndsngap (AT) island (DOT) net> wrote

Quote:
How do I know when to use the "Case" script steps as opposed to the
"If/Else" script steps?
I have experimented with both and seem to have more success with
"Case" but don't know when each is indicated.




Reply With Quote
  #6  
Old   
CRC123
 
Posts: n/a

Default Re: Case or If/Else - 02-08-2007 , 09:50 AM



Thanks all - very helpful.
And apologies to M. Sclossberg for my sloppy language, however, my
question was well answered.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.