[Gambas-user] Merry Christmas and silly problem

Dag JNJ gambas at cd-bahia.com
Mon Dec 26 12:51:39 CET 2022


Hi and thank you very much Lee and BB
I can see my error - shame on me. Only excuse: it was late.  😅
Regards Dag

On 26.12.22 04:55, BB wrote:
>
> On 26/12/22 1:12 pm, T Lee Davidson wrote:
>> On 12/25/22 19:29, Dag JNJ wrote:
>>> First now I got my PC to run again with Matte 22.04.1 and put the 
>>> settings ok. Installed the latest version of Gambas 3.16.3 from the 
>>> repository
>>>
>>> |sudo add-apt-repository universe sudo apt update (even if add 
>>> repository makes this now) sudo apt install gambas3 |
>>>
>>>
>>> with no error.
>>>
>>> The silly problem looks like this:
>>> /
>>> //  Select Case mn//
>>> //    Case mn <= 100//
>>> //      iv = 10//
>>> //    Case mn <= 1000//
>>> //      iv = 100//
>>> //    Case mn <= 10000//
>>> //      iv = 1000//
>>> //    Case mn <= 100000//
>>> //      iv = 10000//
>>> //    Default //
>>> //      iv = 10//
>>> //  End Select
>>>     stop
>>>
>>> /mn has the value 530, so iv should be 100. iv is for interval. mn 
>>> is max number.
>>> It always get the default value 10. I have a halt at select case, so 
>>> I followed the single steps.
>>> And made
>>> /?//mn <= 100//(=false, correct)
>>> ? ///mn <= 1000//(=true, also correct)
>>> //
>>> The iv=100 should have been taken, I simply can't see why not.
>>
>> Your syntax is wrong in the Case statements. Try:
>> [code]
>>   Select Case mn
>>     Case 0 To 100
>>       iv = 10
>>     Case 101 To 1000
>>       iv = 100
>>     Case 1001 To 10000
>>       iv = 1000
>>     Case 10001 To 100000
>>       iv = 10000
>>     Default
>>       iv = 10
>>   End Select
>> [/code]
>>
>> Or, the way I think you were actually wanting to make it work:
>> [code]
>>   Select Case True
>>     Case mn <= 100
>>       iv = 10
>>     Case mn <= 1000
>>       iv = 100
>>     Case mn <= 10000
>>       iv = 1000
>>     Case mn <= 100000
>>       iv = 10000
>>     Default
>>       iv = 10
>>   End Select
>> [/code]
>>
>> :-)
>> or just
> [code]
>   Select Case mn
>     Case To 100
>       iv = 10
>     Case To 1000
>       iv = 100
>     Case To 10000
>       iv = 1000
>     Case  To 100000
>       iv = 10000
>     Default
>       iv = 10
>   End Select
>
> [/code]
>
> It should just drop out of the select chain on the first true
>
> b
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----



More information about the User mailing list