Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
If statement with 23 conditions
Message
 
To
17/01/2006 11:58:51
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01087587
Message ID:
01087595
Views:
11
Mike,

There are lots of ways to skin this cat. One way is just to wrap the line like this:
IF CONDITION1 = RESULT1 ;
    AND CONDITION2 = RESULT2 ;
    AND CONDITION3 = RESULT3 ;
    ... ;
    AND CONDITION23 = RESULT23
  lcReturn = .t.
ELSE
  lcReturn = .f.
ENDIF
Another way is by use of a CASE statement:
lcReturn = .f.
DO CASE
  CASE CONDITION1 # RESULT1
  CASE CONDITION2 # RESULT2
  CASE CONDITION3 # RESULT3
  CASE ...
  CASE CONDITION23 # RESULT23
  OTHERWISE
    lcReturn = .t.
ENDCASE
HTH,
Chad


>Hello,
>I am about to write an ugly IF statement with 23 conditions. What is the best syntax to do this so I don't have one huge IF line. I would like it to be readable without having to scroll a mile to the right.
>
>
>IF CONDITION1 = RESULT1 AND CONDITION2 = RESULT2 AND CONDITION3 = RESULT3...
>     lcReturn = .T.
>Else
>     lcReturn = .F.
>ENDIF
>
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform