Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: David Mustakim
  Where is David Mustakim?
 Jakarta
 Indonesia
 David Mustakim
 To: Tony Vignone
  Where is Tony Vignone?
 St Augustine
 Florida - United States
 Tony Vignone
 Tags
Subject: RE: IF and IIF are not the same
Thread ID: 396238 Message ID: 396243 # Views: 65 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Thursday, January 23, 2014 10:48:28 PM         
   


> Consider this IF:
>
> a = 77
>
>
namea = "a"
> IF EMPTY(namea) THEN    && FALSE
> 	b = 0
> ELSE
> 	b = &namea
> ENDIF
> ?b
> *------------------
> namea = ""
> IF EMPTY(namea) THEN    && TRUE
> 	b = 0
> ELSE
> 	b = &namea
> ENDIF
> ?b

> In the first IF, the ELSE is invoked.
> In the second IF the ELSE is not invoked so an error will not occur.
>
>
>
> Now consider this equivalent IIF: (it is NOT equivalent when run)
>
>
namea = "a"
> ?IIF(EMPTY(namea),0,&namea)
> namea = ""
> ?IIF(EMPTY(namea),0,&namea)
> 

> In the second IFF, an error occurs on the ELSE part. In other words both the IF and the ELSE parts are evaluated regardless of the truth of the condition tested.
>
> I consider this a bug in VFP. It should have returned 0 and ignored &namea the same way the second IF did above.
>
> Tony


Actually this part:
namea = "a"
? IIF(EMPTY(namea),0,&namea)
is likely to error because "&namea" (with preceding ampersand "&") would translate to variable named a which is non-existent

David

ENTIRE THREAD

IF and IIF are not the same Posted by Tony Vignone @ 1/23/2014 10:25:12 PM
RE: IF and IIF are not the same Posted by Rick C. Hodgin @ 1/23/2014 10:45:23 PM
RE: IF and IIF are not the same Posted by Tony Vignone @ 1/24/2014 4:59:33 PM
RE: IF and IIF are not the same Posted by Rick C. Hodgin @ 1/24/2014 7:19:52 PM
RE: IF and IIF are not the same Posted by Tony Vignone @ 1/24/2014 8:51:43 PM
RE: IF and IIF are not the same Posted by Victor Espina @ 1/24/2014 10:48:57 PM
RE: IF and IIF are not the same Posted by David Mustakim @ 1/23/2014 10:48:28 PM
RE: IF and IIF are not the same Posted by Cetin Basoz @ 1/24/2014 1:19:08 AM
RE: IF and IIF are not the same Posted by Tony Vignone @ 1/24/2014 5:10:56 PM
RE: IF and IIF are not the same Posted by Vilhelm-Ion Praisach @ 1/24/2014 3:33:36 AM
RE: IF and IIF are not the same Posted by Tony Vignone @ 1/24/2014 5:11:48 PM
RE: IF and IIF are not the same Posted by Vilhelm-Ion Praisach @ 1/24/2014 7:52:01 PM
RE: IF and IIF are not the same Posted by Tony Vignone @ 1/24/2014 8:53:04 PM
RE: IF and IIF are not the same Posted by Paul Gibson @ 1/24/2014 10:18:04 AM
RE: IF and IIF are not the same Posted by Tony Vignone @ 1/24/2014 5:14:00 PM