Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IIF() Evaluates Differently Than IF?
Message
 
To
12/08/1997 17:39:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00044321
Message ID:
00044639
Views:
29
Ok, all together now, everyone kick me. Yes, this is what I get for staying up too late programming. Heh, after using iif() for all this time correctly my mind just decides to try something different for no apparent reason. :).

>>Here's an odd one. The following code returns two different answers, even though they should be identical:
>>
>>****************
>>* The following code makes vp_dbfname = ""
>>****************
>>iif(EMPTY(thisform.ctextbox1.Value),vp_dbfname = "", ;
>> vp_dbfname = thisform.ctextbox1.Value)
>>
>>****************
>>* This code makes vp_dbfname = thisform.ctextbox1.Value
>>****************
>>if EMPTY(thisform.ctextbox1.Value)
>> vp_dbfname=""
>>else
>> vp_dbfname = thisform.ctextbox1.Value
>>endif
>
>Hi Michael!
>
>IIF() is something diiferent, than you think it.
>
>The sintax of IIF() is:
>
>IIF(lExpression, eExpression1, eExpression2)
>
>In your example, you don't use expression, instead, you use a statement. (assigment) But VFP, in this case thinks, that it is an expression, and it evaluates it. VFP tests the equality.
>And depending on the result, gives .T. or .F., depending on the value of vp_dbfname.
>IIF is a function, which gives back either the value of the first, or the value of the second expression.
>So, you should use:
>
>vp_dbfname = iif(EMPTY(thisform.ctextbox1.Value), "", thisform.ctextbox1.Value)
>
>Good luck!
>
>BB

Michael G. Emmons
memmons@nc.rr.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform