Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
If statement with 23 conditions
Message
From
17/01/2006 12:11:09
 
 
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:
01087598
Views:
7
>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
>
Well If I'd got myself into such a state :-) :
IF  CONDITION1 = RESULT1 ;
AND CONDITION2 = RESULT2 ;
AND CONDITION3 = RESULT3...
     lcReturn = .T.
Else
     lcReturn = .F.
ENDIF

or maybe:

llOverall = ( CONDITION1 = RESULT1)
llOverall = llOverall AND ( CONDITION2 = RESULT2)
llOverall = llOverall AND ( CONDITION3 = RESULT3)
...

If llOverall
     lcReturn = .T.
Else
     lcReturn = .F.
ENDIF
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Reply
Map
View

Click here to load this message in the networking platform