Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:23 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMBASIC MAKING COLOURS VARIABLE

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 06:13am 22 Nov 2023
Copy link to clipboard 
Print this post

Is it possible to make foreground and background colours variables?
Like BGColour$="RGB(100,100,100) and use the string in a TEXT string?

0A47
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6099
Posted: 06:54am 22 Nov 2023
Copy link to clipboard 
Print this post

colours are a number so MYbackground% = RGB(100,100,100)
then use MYbackground where ever you would use RGB(x,x,x)


Jim
VK7JH
MMedit   MMBasic Help
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 08:05am 22 Nov 2023
Copy link to clipboard 
Print this post

Thanks Jim, I should have added more information to my predicament. I am trying to use an array to hold the sections of the TEXT command and I if I use a String array I can extract the X and Y co-ordinates, the FONT and SCALE using VAL() , the actual TEXT string is Ok but I cant see a simple way around holding the foreground and background information unless I use 6 more elements to the array.

0A47
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9122
Posted: 08:08am 22 Nov 2023
Copy link to clipboard 
Print this post

The colour is just a number so yo only need two elements. i.e.
rgb(128,128,128) = &H808080 = 8421504
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 08:13am 22 Nov 2023
Copy link to clipboard 
Print this post

You could put the colours into an integer array
c%(2)=(RGB(yellow),RGB(40,40,40),rgb(white))
then store c%(n) as CHR$(c%(n)) in your string

Is that what you mean?
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 08:17am 22 Nov 2023
Copy link to clipboard 
Print this post

Peter how would you elegantly recover the RGB(XXX,XXX,XXX) from a saved string of "8421504"?
0A47
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9122
Posted: 08:20am 22 Nov 2023
Copy link to clipboard 
Print this post

  Quote   Peter how would you elegantly recover the RGB(XXX,XXX,XXX) from a saved string of "8421504"?X


You don't need to - just use 8421054 in the TEXT command

TEXT 0,0,"hello",,,,8421054,0

is perfectly valid
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 08:23am 22 Nov 2023
Copy link to clipboard 
Print this post

Peter thank you very much. That solves my dilemma instantly.
I have not seen the commands using the numerical form of RGB(xxx,xxx,xxx) before.

0A47
Edited 2023-11-22 18:47 by OA47
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024