Author Topic: Coding that isn't related to BL/Torque problem. [Small Basic]  (Read 1136 times)

It's something that previews RGB and Hex colors, but the Hex portion is only working 50%. I'm very new to this stuff, and I couldn't figure it out.

If I were to type in a hex color containing no letters (990000), it comes out as black. Anyone know why?

EDIT: Also, if there's a formula to convert RGB to Hex and vice versa, let me know.

Code: [Select]
begin:

TextWindow.Clear()
TextWindow.Write("Hex (RRGGBB) or RGB (RRR, GGG, BBB)?")
hexorrgb = TextWindow.Read()
If hexorrgb = "Hex" Or hexorrgb = "hex" Then
  Goto Hex
ElseIf hexorrgb = "RGB" or hexorrgb = "rgb" then
  Goto RGB
  endif
  

RGB:
TextWindow.Clear()
TextWindow.Write("Enter a value for Red: ")
red = TextWindow.Read()
If red > 255 Then
  TextWindow.Write("ERROR: Value must be less than 255, please restart.")
  Program.Delay(1500)
  TextWindow.Clear()
  Goto RGB
  endif
TextWindow.Write("Enter a value for Green: ")
green = TextWindow.Read()
If green > 255 Then
  TextWindow.Write("ERROR: Value must be less than 255, please restart.")
  Program.Delay(1500)
  TextWindow.Clear()
  Goto RGB
  endif
TextWindow.Write("Enter a value for Blue: ")
blue = TextWindow.Read()
If blue > 255 Then
  TextWindow.Write("ERROR: Value must be less than 255, please restart.")
  Program.Delay(1500)
  TextWindow.Clear()
  Goto RGB
  endif
TextWindow.WriteLine("Showing RGB: " + red + ", " + green + ", " + blue)
bgcolor = GraphicsWindow.GetColorFromRGB(red, green, blue)
GraphicsWindow.Title = "RGB " + red + ", " + green + ", " + blue
GraphicsWindow.Height = 128
GraphicsWindow.Width = 384
GraphicsWindow.BackgroundColor = bgcolor
TextWindow.WriteLine("")
TextWindow.WriteLine("Press X to close, or R to restart.")
doagain = TextWindow.Read()
If doagain = "X" Or doagain = "x" Then
  Program.End()
ElseIf doagain = "R" or doagain = "r" then
  Goto begin
EndIf

Hex:

TextWindow.Write("Enter a value for Red: ")
red = TextWindow.Read()
TextWindow.Write("Enter a value for Green: ")
green = TextWindow.Read()
TextWindow.Write("Enter a value for Blue: ")
blue = TextWindow.Read()
TextWindow.WriteLine("Showing Hex: " + red  + green + blue)
bgcolor = red + green + blue
GraphicsWindow.Title = "HEX " + red + green + blue
GraphicsWindow.Height = 128
GraphicsWindow.Width = 384
GraphicsWindow.BackgroundColor = "#" + bgcolor
TextWindow.WriteLine("")
TextWindow.WriteLine("Press X to close, or R to restart.")
doagain = TextWindow.Read()
If doagain = "X" Or doagain = "x" Then
  Program.End()
ElseIf doagain = "R" or doagain = "r" then
  Goto begin
EndIf

Screenshots below.
« Last Edit: July 17, 2010, 04:26:45 PM by TheBlackParrot »

Well i believe any combination of just numbers will give you black and dark grey.

Well i believe any combination of just numbers will give you black and dark grey.
Do you even know what Hex colors are? :I

What language is this?
Small Basic?

What language is this?
Small Basic?

Quote from: topic title
[Small Basic]

Do you even know what Hex colors are? :I
Umm same colors that are used in blockland right for like colors in client events?

Umm same colors that are used in blockland right for like colors in client events?
Yeah, those.

I do know 990000 is dark red, pretty much anything that looks similar to that hex value is dark.

What do you write this in? I've been doing calculator basic for a while and I've been wanting to write stuff on the computer.

What do you write this in? I've been doing calculator basic for a while and I've been wanting to write stuff on the computer.
http://smallbasic.com/