GLBasic forum

Main forum => Bug Reports => Topic started by: MrTAToad on 2011-Jan-04

Title: SELECT and result from a function
Post by: MrTAToad on 2011-Jan-04
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...
Title: Re: SELECT and result from a function
Post by: Slydog on 2011-Jan-04
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?
Title: Re: SELECT and result from a function
Post by: MrTAToad on 2011-Jan-05
By ignored, I think SELECT thinks that a value of 0 should be used instead of the value returned by the function.
Title: Re: SELECT and result from a function
Post by: Kitty Hello on 2011-Jan-05
the function call will be repeated for each case :S
Please use a constant here. I think I have to fix that one day.
Title: Re: SELECT and result from a function
Post by: hardyx on 2011-Jan-05
In this case is more efficient to save the funcion result in a variable.   =D