SELECT and result from a function

Previous topic - Next topic

MrTAToad

I've found that, for some reason, when using the result of a function as the value in a SELECT statement, the result is sometimes ignored.
 
For example :

Code (glbasic) Select
SELECT setup.doOptions(userOptions)
case 0
case 1
case 2
ENDSELECT


will always call the CASE 0 no matter what the return value is.  Using a variable to store the result of the function call solves the problem, but can be inefficient.

And I had a case of the dreaded X problem today too for some reason...

Slydog

#1
And I assume since it 'will always call the CASE 0', it ONLY calls CASE 0?

I wonder if it could be the return type of the 'doOptions()' routine?  Is it '%'?
[Edit] And you said 'the result is sometimes ignored', does that mean sometimes using a function does work?
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

MrTAToad

By ignored, I think SELECT thinks that a value of 0 should be used instead of the value returned by the function.

Kitty Hello

the function call will be repeated for each case :S
Please use a constant here. I think I have to fix that one day.

hardyx

In this case is more efficient to save the funcion result in a variable.   =D