11-07-2022, 09:45 PM
(11-07-2022, 09:41 PM)Pete Wrote: This looks like a job for SELECT CASES Which we don't have.
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.
What we need is an AND IS statement.
CASE IS > 50, AND IS < 70