The advantages are simple...

If you have N ElseIf's next to eachother on the same level,
if ElseIf X evaluates to true, then you will have N-X ElseIf's that don't
even have to be evaluated.  If you assume that the probability of being true
for your ElseIf checks is evenly distributed among the N options, then you
will end up with, on average only half of the ElseIf checks actually having
to execute the conditional check.

The same chunk of code with a series of only If actions will always have to
evaluate expression for every If check.  So, making some pretty bold
assumptions, the actual overhead of the If Else Structure, (not counting the
programming logic inside of these branches) could be somewhere around twice
as fast using ElseIfs instead of a bunch of If's.

Now, if you think about it.  If you have a serise of ElseIf's and you put
the conditions that are more likely to occur higher in the taf file, you
will end up with even more speed increase, because your average number of
ElseIf's that get executed will not be N/2, but something smaller.

ElseIf's should always be used if they properly represent the logic that you
want to execute.  (conditions are mutually exclusive)

A string of only If's should only be used if your conditions are not
mutually exclusive, and you WANT it to be possible for more than 1 of them
to execute in a given request for that taf, or tcf method.


What I have given you is a generic computer science answer that applies to
any language, including WiTango.  Unless of course some idiot at Pervasive
wrote some terrible code that made ElseIfs 10 times more expensive in CPU
cycles than If's.

/John



----- Original Message -----
From: "Dan Stein" <[EMAIL PROTECTED]>
To: "Multiple recipients of list witango-talk" <[EMAIL PROTECTED]>
Sent: Wednesday, August 28, 2002 2:12 PM
Subject: Witango-Talk: If vs. ElseIf


> Has any work been done on documenting the relative speed and or advantages
> of using as series of If actions in your taf file vs. one If and a series
of
> ElseIf's.
>
> This is of course actions all at the same level.
>
> Dan
> --
> Dan Stein
> Digital Software Solutions
> 799 Evergreen Circle
> Telford PA 18969
> Land: 215-799-0192
> Mobile: 610-256-2843
> Fax 413-410-9682
> FMP, WiTango, EDI,SQL 2000
> [EMAIL PROTECTED]
> www.dss-db.com
>
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
>                 with unsubscribe witango-talk in the message body

________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to