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...
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!
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!