General information
Category:
Coding, syntax & commands
Cindy:
Thanks for your reply :o)
I did create a test, and still trying diffrent methods. So far, I've found that the IF's return a little faster. Is this a fact or is it just the way I'm setting up my code? Do you see a problem in using a whole bunch of IF/ENDIF's in place of a DO CASE?
TIA
Mal
>Mal,
>
>>Feeling that IF's are faster than DO CASES, thought I'd ask.
>
>Don't just "feel" - if it's important, test. Make a program with a jillion loops and put your IF or your CASE code in the middle and run it.
>
>>
>>Besides code readability, do you see any problems by replacing DO CASE with IF's.?
>>
>>DO CASE
>>..CASE x="whatever1"
>>.....DO something
>>..CASE x="whatever2"
>>.....DO something
>>.....
>>..CASE x="whatever24"
>>.....DO something
>>ENDCASE
>>RETURN
>>
>>.OR.
>>
>>IF x="whatever1"
>>..DO something
>>..RETURN
>>ENDIF
>>
>>IF x="whatever2"
>>..DO something
>>..RETURN
>>ENDIF
>>
>>.......
>>
>>IF x="whatever24"
>>..DO something
>>..RETURN
>>ENDIF
>
>The problem with the code you have here is that CASE stops after the first true statement is encountered. Your IF code will do the first Something if it's true, and then go on to test for the second condition, and do the second Something also. To be equivalent to the CASE statement you would need to ELSE and nest the IFs inside that.
>IF
> * do something
>ELSE
> IF
> * do something
> ELSE
> IF ....
> ENDIF
>ENDIF
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only