so you needed the Val(Str()) to make floats work correctly?
what I see at first glance is that your expression in your Macro is not in brackets.
this could lead to problems sometimes.
try
Code: Select all
Macro IIFnumerical(expr,y,n)
( (y) * ( 1 And (expr) ) + (n) * (Not (1 And (expr) )) )
EndMacro
also, take a look here:
http://www.purebasic.fr/english/viewtop ... 31#p303631
PS:
it's really strange why ( 1 And (expr) ) does not work with the Len()...
I diddled around abit and came up with this:
Code: Select all
Macro IIF(expr,y,n)
Right( y ,Len(y) * ( Not ( Not (expr) ) ) ) + Right( n ,Len(n) * (Not (expr) ) )
EndMacro
Debug IIF(5.5 < 5.5,"Yes","No")
Debug IIF(5.5 < 5.7,"Yes","No")
at least the messy superflous string-operation is eliminated...
PPS:
ok, I found a dirty,
dirty,
dirty hack:
Code: Select all
Macro IIF(expr,y,n)
Mid( y + n , Len( y ) * ( Not (expr) ) +1 , Len ( y ) )
EndMacro
Debug IIF(5.5 < 5.5, "yes", "no")
Debug IIF(5.5 < 5.7, "yes", "no")
the expression is only evaluated once,
but it only works if the true-string is longer or at least same length.
if the false-string is longer, it will be cut.
oh... and have a nice day.