Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hate Nested IFs? Consider this...
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Hate Nested IFs? Consider this...
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01086217
Message ID:
01086217
Views:
66
Jim,

I took this from your comments in the GLGDW thread...

>Some people hate (with a capital H) nesting of IFs simply because they can't stand the indenting. I don't worry about how much indenting is done.

Here is a tip as an alternate to nested IFs that I use just because it is easier for ME to follow:
local llSuccess
llSuccess = .T.
DO CASE
   CASE NOT 1st_Logical_Test
       llSuccess = .F.
   CASE NOT 2nd_Logical_Test
       llSuccess = .F.
   CASE NOT 3rd_Logical_Test
       llSuccess = .F.
   OTHERWISE
       llSuccess = .T.
ENDCASE
RETURN llSuccess
Just remove the "llSuccess = .F." lines above or the "OTHERWISE" clause depending on your preference. That DO CASE is the same as --
LOCAL llSuccess
llSuccess = .F.
IF 1st_Logical_Test
   IF 2nd_Logical_Test
      IF 3rd_Logical_Test
         llSuccess = .T.
      ENDIF
   ENDIF
ENDIF
RETURN llSuccess
Mark McCasland
Midlothian, TX USA
Next
Reply
Map
View

Click here to load this message in the networking platform