Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Xbase DO CASE indention
Message
General information
Forum:
Humor
Category:
Other
Miscellaneous
Thread ID:
01564657
Message ID:
01564776
Views:
41
That's how I tested it, though my top test was OS() = "5". :-) Very difficult to debug. A cursory glance and you're thinking you've just learned that ELSE and OTHERWISE are interchangeable.

In the VXB++ Visual FreePro xbase language I've added two extensions to DO CASE code paths. The first will always execute a block of code before it enters any CASE condition. The second will always execute a block of code afterward if it entered any CASE condition.
DO CASE
    ALWAYS BEFORE
        * Code to execute if someCondition1, or someCondition2 match, before those code blocks are run

    CASE someCondition1
        * Code for this case condition here

    CASE someCondition1
        * Code for this case condition here

    OTHERWISE
        * Code to execute if neither conditions were true

    ALWAYS AFTER
        * Code to execute if someCondition1, or someCondition2 match, before those code blocks are run
ENDCASE
In the above, if someCondition1 was true, the sequence would be:
(1) ALWAYS BEFORE code block
(2) the CASE someCondition1 code block
(3) the ALWAYS AFTER code block
(4) exit the DO CASE

If neither was true, the sequence would be:
(1) OTHERWISE code block
(2) exit the DO CASE

I've also added a conditional clause on entry into the DO CASE, which is like:
DO CASE someCond
ENDCASE
Which is like:
IF someCond
    DO CASE
    ENDCASE
ENDIF
>>>>I propose a new law that says everyone who does not indent the CASE lines in a DO CASE...ENDCASE should be fined $1500 per instance.
>>>>
>>>>:-)
>>>
>>>
>>>IF I could get just $1 for each instance of code that I do not like it, I would be rich, RICH!
>>>
>>>The most expensive fine I would deal would be for those coders that use ELSE instead of OTHERWISE in a case statement, it is JUST PLAIN WRONG!!! :)
>>
>>
>>I did not even know you could do that. I tried it just now and it compiled without error, but it seems like it's dead code that's never accessed. The behavior was different than OTHERWISE.
>>
>>What does an ELSE do in a DO CASE?
>
>Well, as I said, it is plain wrong :) (but I saw code that uses ELSE several times, unfortunately no error it just ignores it making difficult to debug)
>
>
>do case
>	case .f.
>		? 'False'
>	*otherwise
>	else
>		? 'True'
>endcase
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform