Select Case mistake
#5
This looks like a job for SELECT CASES Which we don't have. Sad

From my other thread: https://staging.qb64phoenix.com/showthre...LECT+CASES

We have a split between devs on putting it into QB64 so who knows, maybe someday.

Anyway, don't get fooled by whatever the heck this is...

Code: (Select All)
a = 1600
SELECT CASE a
    CASE IS > 500, IS < 700
        PRINT "Wrong!"
END SELECT

Funny it looks like it should work, but of course it won't; but I find it curious we can divide up CASE statements with commas like this. So I don't get the logic here. This sample will print "Wrong!" when it should print nothing, as 1600 is > 500 but NOT smaller than 1600 to satisfy an a > 500 AND a < 700, BUT AGAIN, no "AND" SO THIS IS NOT WHAT THE CODE IS SET UP TO DO. So what is the comma use is set up to do? I'd have to go research that a bit to figure it out. I just thought I'd bring it up for the fun of it. I just use what mn demonstrated when I need these SELECT CASES (we don't have) situations.

Did I mention we don't have SELECT CASES?

EDIT: Nice, I see Steve addressed the comma issue. I've used the CASE TO range method as well, but apparently not recently enough for it to be on the tip of my brain. Yeah, it gets pretty pointy under that big hat I wear.

Pete

We don't have SELECT CASES, varmint!
Reply


Messages In This Thread
Select Case mistake - by Kernelpanic - 11-07-2022, 09:09 PM
RE: Select Case mistake - by mnrvovrfc - 11-07-2022, 09:19 PM
RE: Select Case mistake - by SMcNeill - 11-07-2022, 09:35 PM
RE: Select Case mistake - by SMcNeill - 11-07-2022, 09:29 PM
RE: Select Case mistake - by Pete - 11-07-2022, 09:41 PM
RE: Select Case mistake - by SMcNeill - 11-07-2022, 09:45 PM
RE: Select Case mistake - by Pete - 11-07-2022, 09:52 PM
RE: Select Case mistake - by mnrvovrfc - 11-07-2022, 10:14 PM
RE: Select Case mistake - by Pete - 11-07-2022, 10:20 PM
RE: Select Case mistake - by mnrvovrfc - 11-07-2022, 10:27 PM
RE: Select Case mistake - by Kernelpanic - 11-07-2022, 10:21 PM
RE: Select Case mistake - by Kernelpanic - 11-07-2022, 10:36 PM
RE: Select Case mistake - by Kernelpanic - 11-08-2022, 02:57 PM
RE: Select Case mistake - by Pete - 11-08-2022, 03:28 PM
RE: Select Case mistake - by SMcNeill - 11-08-2022, 03:58 PM
RE: Select Case mistake - by Pete - 11-08-2022, 04:17 PM
RE: Select Case mistake - by Kernelpanic - 11-08-2022, 04:21 PM
RE: Select Case mistake - by Pete - 11-08-2022, 04:28 PM
RE: Select Case mistake - by Kernelpanic - 11-08-2022, 04:28 PM



Users browsing this thread: 8 Guest(s)