General information
Category:
Coding, syntax & commands
Mal,
I didn't notice the RETURNs after the IFs so your code would really only do the first true choice.
>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
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