Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using CONST & _RGB used together seem to error...
#1
I've noticed only _RGB32 colors can be assigned using CONST, not _RGB ones.  Is this a bug?

'these aren't allowed...
Const bgcolor1~& = _RGB(50, 50, 50)
Const bgcolor2~& = _RGBA(50, 50, 50, 50)

'these are allowed...
Const bgcolor3~& = _RGB32(50, 50, 50)   
Const bgcolor4~& = _RGBA32(50, 50, 50, 50)

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#2
(12-11-2025, 07:43 PM)Dav Wrote: I've noticed only _RGB32 colors can be assigned using CONST, not _RGB ones.  Is this a bug?

'these aren't allowed...
Const bgcolor1~& = _RGB(50, 50, 50)
Const bgcolor2~& = _RGBA(50, 50, 50, 50)

'these are allowed...
Const bgcolor3~& = _RGB32(50, 50, 50)   
Const bgcolor4~& = _RGBA32(50, 50, 50, 50)

- Dav

Check the Type _RGB and _RGBA come in I am pretty sure it is NOT Unsigned Long like _RGB32 and _RGBA32 are, maybe just Long?

Update: Help says Long type but shows example with myColor~& = _RGB(blah, blah, blah) so why is that?
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#3
I'm not sure, I can't seem to assign a _RGB color with CONST using a variable name.  

I gotta jet to a concert now, but I'm sure when I get back I will have see I've embarrassed myself again with an idiot mistake. lol.    Thanks for the quick reply bplus...

Smile

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#4
I just plugged in first line to test, only the _RGB and IDE says wrong number of arguments???

I add a 4th = 0 on the end and all is well.

This is OK:
Code: (Select All)
Const bgcolor1~& = _RGB(50, 50, 50, 0)
Const bgcolor2& = _RGBA(50, 50, 50, 50, 0)

the missing number is image handle, 0 for current screen I think. Apparently the optional screen handle is NOT Optional in Const???

Doesn't seem like stupid mistake, Const use smells funky Smile
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#5
Hey, Dav. I tried it on my PC and got the same issue. However, I noticed another bug as well. If you rename your top two consts to just bgcolor and give them the same values you had before, (obviously commenting out one or the other because you can't have two of the same name), the IDE will give an error about the wrong number of arguments for those functions! For some reason, when used in const, the IDE enforces the 4th optional argument!

   
Now, add the 4th argument...:
   
The noticing will continue
Reply
#6
(12-11-2025, 08:04 PM)SpriggsySpriggs Wrote: Hey, Dav. I tried it on my PC and got the same issue. However, I noticed another bug as well. If you rename your top two consts to just bgcolor and give them the same values you had before, (obviously commenting out one or the other because you can't have two of the same name), the IDE will give an error about the wrong number of arguments for those functions! For some reason, when used in const, the IDE enforces the 4th optional argument!


Now, add the 4th argument...:

But try the last 2 lines without the first 2 and back to missing argument thing again??

I say its a bug but Steve will tell us it is a feature LOL!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#7
The missing 4rth argument is alpha (transparency), I think.
Reply
#8
Allow me to clarify this for everyone with a few simple questions and answers. 

RED = _RGB(255, 0, 0)

Now, somebody tell me what number that RED is.   Anyone.  Please!

With the information provided above, you absolutely can't tell me what that value is.

In SCREEN 0, it would be color 4.
In SCREEN 13, it would be color 40.
In SCREEN _NEWIMAGE(x, y, 256), it would be 40.
In SCREEN _NEWIMAGE(x, y, 32), it would be &HFFFF0000~&.

By itself, it's... undefined.  Impossible to calculate.  It's NAN, if it's anything.
You have to know the SCREEN mode to be able to determine what that color number is.

_RGB is a transformative function which returns a value based upon the screen mode it's associated with.

So when we do this:

CONST RED = _RGB(255, 0, 0)

What screen is that associated with?   Is your red on a SCREEN 0 text screen?  OR are you looking for red on a 256 color screen?  How about on SCREEN 7?   How the BLEEP is CONST supposed to know that???   

---------

So.... How would one fix this?

Wouldn't you simply SPECIFY THE SCREEN MODE??

CONST RED = _RGB(255, 0, 0, 0) 'This is color 4, because it's on SCREEN 0 as defined in that last parameter.
CONST RED = _RGB(255, 0, 0, 256) 'This is color 40, because it's on a 256 color screen.

You need an extra parameter with _RGB and CONST to specify the screen mode from which you want to get your color value.  

@bplus was close when he said he thought it was an image handle, but it's not an image handle.  It's the SCREEN MODE.



And _RGB32 doesn't have this same need to specify a screen mode as it *ONLY* returns values for a 32-bit color screen.



So this is *not* a bug.  It's a design feature so you can specify which screen mode you want to use _RGB with and associate those values with for the proper color match on that screen mode.
Reply
#9
Example for folks to quickly run and test:

Code: (Select All)
Const Red0 = _RGB(255, 0, 0, 0) 'Screen 0
Print Red0
Const Red12 = _RGB(255, 0, 0, 12) 'Screen 12
Print Red12
Const Red13 = _RGB(255, 0, 0, 13) 'Screen 13
Print Red13
Const Red256 = _RGB(255, 0, 0, 256) 'Screen 256
Print Red256
Const Red32 = _RGB(255, 0, 0, 32) 'Screen 32
Print " "; Hex$(Red32)
Reply
#10
LOL told you it's going to be a feature!

But if the 4th parameter is supposed to be Screen Mode then somebody better update the Wiki because there it says ImageHandle&.
   
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mac debugger not connecting, a user error! BlameTroi 0 99 02-07-2026, 06:18 PM
Last Post: BlameTroi
  ERROR MESSAGES COLORS ? aurel 5 379 01-02-2026, 11:26 AM
Last Post: aurel
  error doing image collision detection with _MemGet madscijr 55 4,652 10-01-2025, 03:25 PM
Last Post: bplus
  Using CONST Dimster 15 1,299 08-12-2025, 07:27 PM
Last Post: Kernelpanic
  error on function returning _mem Herve 5 677 07-05-2025, 08:06 PM
Last Post: hsiangch_ong

Forum Jump:


Users browsing this thread: 1 Guest(s)