I wonder if there is a deeper difference between an If statement and a Select statement?
The obvious answer is a Select statement visits each condition until a match is made.
I couldn’t find a comparable in XOJO discussion. In the Realsoftware I found one discussion
What are your thoughts?
DerkJ
(DerkJ)
July 26, 2020, 4:19pm
2
If i’m right shere should be a difference since select case does a single type compare and if…else does multiple (1 on ech if(else)).
There should be a topic on this forum about this
DerkJ
(DerkJ)
July 26, 2020, 4:19pm
3
Thanks. It didn’t show in the search
@Arthur Gabhart If you talk about speed, “if…then” is more efficient. If you talk about versatility, “select case” can handle more cases very easily
I saw some ideas in the other post. Flexibility is nice.
I particularly like this example
[code]select case testvar
case 4,5,6
msgbox “Evaluated First”
case 6
msgbox “This one fired too” --never fires
case 8
Msgbox “not me”
case else
end select[/code]
Doesn’t a SELECT CASE list “short-circuit” to the END SELECT as soon as it has found a condition that satisfies a CASE statement?
I normally use a SELECT CASE for the sake of readability (IMHO view anyway) instead of multiple ELSEIF statements.
That is correct.
From the LR for Select Case