#81664 - 2003-06-02 04:16 AM
IIF enhancement
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
It appears that when one uses an IIF(condition,Exp1,Exp2), both Exp1 and Exp2 are evaluated when only one should be based on the condition.
Ruud, could you please alter the current IIF code so that only one expression is evaluted after the condition is checked?
|
Top
|
|
|
|
#81666 - 2003-06-02 04:44 AM
Re: IIF enhancement
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Bummer Thanks for letting me know.
|
Top
|
|
|
|
#81668 - 2003-06-03 12:16 AM
Re: IIF enhancement
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
quote: or is that too complex?
Not complex, but it won't always work.
One problem is that IIF() returns arbitrary variable types, while your solution appears to be limited to numeric types.
The second problem is variable scope. You will either need to parse variables at the time you call IIF2() in which case it has the same problems as the existing IIF, or you will have to make the variables global.
You can get around the arbitrary type by making an assignment in the Execute
code:
Exit Execute("$$IIF2="+$exp[not not $condition])
But the variable scope problem is a tougher nut to crack.
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 248 anonymous users online.
|
|
|