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: AustraliaPosts: 926 |
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: 6099 |
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: AustraliaPosts: 926 |
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: 9122 |
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: 6798 |
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: 926 |
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: 9122 |
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: 926 |
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 |