Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CASE statements
Message
From
21/10/2003 18:08:20
 
 
To
21/10/2003 17:54:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00838740
Message ID:
00840866
Views:
26
Hi Elmer,

I don't have any problem with any of the examples you show here.

My aversion is the the CASE statement conditions themselves BEING THE WORK.
In such a circumstance it is specifically coded to have EVERY CASE execute it's "conditional"
expression (in the form of a function) and the conditional test is expressly designed to
evaluate to .F.

My argument is that no average reader of such a kludge will see this, at least not right away,
and so will spend needless frustrating time looking (elsewhere) for the object of their search.

I'm ALL FOR CASEs doing work under each CASE, even if that turns out to only be a single
function call. That way things are clear all around.

Again... strictly PERSONAL preference.

cheers

>I'm not sure that I understand your adversion to Do Case structures doing "work", but everyone is entitled to his own style and standards. I have found DO CASE to be very useful. Especially in "cases" where any one of many conditions is FALSE aborts the work to be done.
>
>Also in "cases" where there is a possibility of multiple positive conditions that may exist but there exists a hierarchy where only one is to be allowed to do some "work" to the exclusion of all other "work" for any of the other lesser significant conditions, DO CASE is ideal. It allows you to avoid multiple nested If/Else/Endif structures or additional flag variables and IMO it provides well formatted code that is possibly easier to read and understand the intent. It may also allow a single exit point without nested if/else/endif or additional flag variables to check for.
>
>m.llCondition1 = .t.
>m.llCondition2 = .f.
>m.llCondition3 = .t. && but do not process if any previous m.llCondition is .t.
>m.llCondition4 = .f.
>
>
>DO CASE
>   CASE m.llCondition1 = .t.
>      *!* do required work when m.llCondition1 is .t. and skip any other processing for other Conditions
>
>   CASE m.llCondition2 = .t.
>      *!* do required work when m.llCondition2 is .t. and skip any other processing for other Conditions
>
>   CASE m.llCondition3 = .t.
>      *!* do required work when m.llCondition3 is .t. and skip any other processing for other Conditions
>
>   CASE m.llCondition4 = .t.
>      *!* do required work when m.llCondition4 is .t. and skip any other processing for other Conditions
>
>   OTHERWISE
>      *!* do required work when no Condition is .t.
>
>ENDCASE
>
>
>
>Or do the same thing with if/endif requires (IMO) confusing nested if/else/endif structures or multiple exit points.
>
>IF m.llCondition1 = .t.
>      *!* do required work when m.llCondition1 is .t. and skip any other processing for other Conditions
>
>ELSE
>
>    IF m.llCondition2 = .t.
>      *!* do required work when m.llCondition2 is .t. and skip any other processing for other Conditions
>
>    ELSE
>         IF m.llCondition3 = .t.
>             *!* do required work when m.llCondition3 is .t. and skip any other processing for other Conditions
>
>         ELSE
>              IF m.llCondition4 = .t.
>                   *!* do required work when m.llCondition4 is .t. and skip any other processing for other Conditions
>
>              ELSE
>                   *!* do required work when no other Condition is .t.
>
>              ENDIF
>         ENDIF
>   ENDIF
>ENDIF
>
>Or using multiple if / endif combined with otherwise unnecessary m.llWorkdone flag
>
>local m.llWorkdone
>m.llworkdone = .f.
>IF m.llCondition1 = .t.
>      *!* do required work when m.llCondition1 is .t. and skip any other processing for other Conditions
>
>      m.llWorkdone = .T.
>ENDIF
>
>IF m.llWorkdone = .f. AND m.llCondition2 = .t.
>      *!* do required work when m.llCondition2 is .t. and skip any other processing for other Conditions
>
>      m.llWorkdone = .T.
>ENDIF
>
>IF m.llWorkdone = .f. AND m.llCondition3 = .t.
>      *!* do required work when m.llCondition3 is .t. and skip any other processing for other Conditions
>
>      m.llWorkdone = .T.
>ENDIF
>
>IF m.llWorkdone = .f. AND  m.llCondition4 = .t.
>      *!* do required work when m.llCondition4 is .t. and skip any other processing for other Conditions
>
>      m.llWorkdone = .T.
>ENDIF
>
>IF m.llWorkdone = .f.
>      *!* do required work when no Condition is .t.
>
>      m.llWorkdone = .T.
>ENDIF
>
>
>
>
>
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform