Select Case mistake
#6
(11-07-2022, 09:41 PM)Pete Wrote: 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?

Pete

We don't have SELECT CASES, varmint!

AS I mentioned:  It works as an OR comparison.  Think of it as:

SELECT CASE 1, 2, 3, 5, 7, 9

^The above is for 1 OR 2 OR 3 OR 5 OR 7 OR 9....

SELECT CASE IS > 50, IS < 70 is basically IF whatever > 50 OR whatever < 70 THEN....   

It's basically bad programmer logic which is going to be true all the time, but it *is* a valid syntax.  Tongue



What we need is an AND IS statement.

CASE IS > 50, AND IS < 70
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: 9 Guest(s)