So I tried delaying evaluation:Function IIF( theCond, theTrue, theFalse ) Dim theResult If theCond Then theResult = theTrue Else theResult = theFalse End If IIF = theResult End Function
Calling it was to work like this,Function EIF( theValue, theTest, theTrue, theFalse ) Dim theResult Dim theBool theTest = Replace( theTest, "$1", "theValue" ) theTrue = Replace( theTrue, "$1", "theValue" ) theFalse = Replace( theFalse, "$1", "theValue" ) theBool = Eval( theTest ) If theBool = True Then theResult = Eval( theTrue ) Else theResult = Eval( theFalse ) End If EIF = theResult End Function
That is, if i = 1 then j = i else j = i * i. If I'd just used IIF it would have beeni = 1 j = EIF(i,"$1=1","$1", "$1*$1")
and the true and false parts would have been evaluated before invocation of the IIF function.i = 1 j = IIF(i=1,i,i*i)
I gave up in the end, but it was fun ... sort of.