Information générale
Catégorie:
Codage, syntaxe et commandes
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
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement