QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: thelowerrhythm on August 24, 2018, 08:55:38 pm
-
Hello, first post. Dusted off a really old machine the other day and was digging through some BAS programs I had been working on. Now I've got the wild hair to finish some of them. I'm still working in Qbasic, but QB64 is on its way down the pipe as I type this.
Fair warning: I'm no programmer. I had barely learned anything when I moved on.
Anyway, this program I've got is supposed to let the user input four strings of text, choose foreground / background colors (or randomize them), and then barf out these strings at random X number of times.
This is the section that always falters:
IF B = 666 AND F = 666 THEN
COLOR FR, BR
ELSEIF B < 666 AND F < 666 THEN
COLOR F, B
ELSEIF B = 666 AND F < 666 THEN
COLOR FR, B
ELSEIF B < 666 AND F = 666 THEN
COLOR F, BR
END IF
B is the background color input by user and F is foreground color input by user, while BR and FR are the randomly generated versions respectively.
If you set both to random by entering 666 for B and F, it works. It also works if both are NOT 666. However, if one is set to random and the other isn't, it always fails, citing the appropriate COLOR line as an Illegal Function Call.
This is a mystery that's about 18 years old, so my future appreciation for any help solving it.
-
Hello there and welcome to the forum.
Is this any sort of demoniac conjuring? A lot of 666 there!
-
It's been a long time since I have used qbasic, but back then, the "general" colors numbered from 0 to 15. (of course this may be different depending on the "screen" number.
As long as B and F are less then 16 pretty much all of it should work. (Do not just take 'my' word for it. I may be wrong as well... lol)
J
ps: More importantly... Welcome to the Forum!!
-
Fillippe,
You snuck in whilst I was typing.... lol
J
-
IF B = 666 AND F = 666 THEN
COLOR FR, BR
ELSEIF B < 666 AND F < 666 THEN
COLOR F, B
ELSEIF B = 666 AND F < 666 THEN
COLOR FR, B
ELSEIF B < 666 AND F = 666 THEN
COLOR F, BR
END IF
It seems to me that 666 is the code to use a random color, and if so, the COLOR statements are reversed.
ELSEIF B < 666 AND F = 666 THEN
COLOR F, BR
For example, in the above, B would be a valid color (less than 666), and F would be the code for FOREGROUND_RANDOMIZED, which should end up being:
ELSEIF B < 666 AND F = 666 THEN
COLOR FR, B
-
Noooo. /facepalm
That was totally it, lol. It was reversed and trying to call the wrong variable in the wrong spot.
I love the fact that my first dip back into this after all this time was just to embarrass myself over a 20 year old problem.
Damn this forum is quick! Thanks everyone!