case statements can have the same values?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: case statements can have the same values?

Post by Axolotl »

Thanks Fred and to all discussants.

It's okay with me that the compiler can't recognize everything.
However, in the case of a select case statement in connection with constants, a warning would not be bad.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PBJim
Enthusiast
Enthusiast
Posts: 294
Joined: Fri Jan 19, 2024 11:56 pm

Re: case statements can have the same values?

Post by PBJim »

Caronte3D wrote: Fri Mar 15, 2024 9:21 am Workaround:

Code: Select all

Select dummy
  Case Bool((acctype = "C") And (amount > cutoff))
    Debug "Case 1"
        .
        .
Interesting, thanks very much Caronte3D. I'd seen Bool() before but didn't see its potential at the time. It seems odd to me though, because Bool() appears in the documentation as a compiler function, which perhaps had lead me to believe it was a compile-time feature, but quite clearly that isn't the case, as it's indeed working well at runtime, the way you've done it. :D
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: case statements can have the same values?

Post by Caronte3D »

Yeah! Put a Bool in your life and be happy! :lol:
Post Reply