![]() |
Forum Index : Microcontroller and PC projects : MMBASIC MAKING COLOURS VARIABLE
Author | Message | ||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
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: AustraliaPosts: 6219 |
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 |
||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
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 KingdomPosts: 10063 |
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 KingdomPosts: 7499 |
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: AustraliaPosts: 982 |
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 KingdomPosts: 10063 |
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: AustraliaPosts: 982 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |