Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
 
To
31/05/2001 13:15:07
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00513303
Views:
16
>Here's a quote from a recent thread:
>
loColumn.DynamicFontBold = "'IIF(THIS.PARENT.gnRecNo = RECNO THIS.PARENT.RecordSource), .T., .F.)'"
>I wouldn't be starting on this if this was the only one, but I'm seeing the IIf({expL}, .T., .F.) just far too often, so I started wondering what made this become customary.
>I've even seen IIF(.T., .F., .F.) in a property (where a string containing a logical expression was expected).
>What I don't understand is why would anyone want to write
>
If DESCENDING()
>	Thisform.lSaveAscending = .F.
>Else
>	Thisform.lSaveAscending = .T.
>Endif
>instead of
>
Thisform.lSaveAscending =NOT DESCENDING()
>Or why is this form
>
llHasValue=iif(empty(lcValueString), .F., .T.)
>preferrable over the
>
llHasValue=not empty(lcValueString)
>Was it a readability issue, or what? I'm still thinking that
>
c=a#b
is more clear and more readable than
>
c=iif(a=b, .f., .t.)
or, worse,
>
if a=b
>   c=.f.
>else
>   c=.t.
>endif
>Is it just my pet peeve, or are there some recommendations about this?

Well, if it's a pet peeve, I can assure you that you're not alone. < Puts on fire suit against the upcoming flames > One thing that I think Foxheads don't handle as well as programmers in some other languages, or at least it used to be so, is the handling of Boolean values. My biggest peeve is the something like the following:
DO WHILE .T.
  * Bunch of code here
  * Leading to...
  IF llcondition
    EXIT
  ENDIF
ENDDO
rather than
llcondition = .F.
DO WHILE NOT llcondition
  * Bunch of code here
  * Including a statement like
  llcondition = < Logical Expression >
ENDDO
Of course, this is just IMO, so I could be wrong.:-)
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform