
-----------------------------------
Jenkinz
Mon Apr 03, 2006 4:58 pm

color text
-----------------------------------
hey guys i need some help, my practical exam is tommorow and iknow how to do everything except change the color of text which the teacher did not or i guess forgot to tell us how to do! if you can show me or or an example it would be appreciated greatly. 

THANKS!

-----------------------------------
HellblazerX
Mon Apr 03, 2006 5:10 pm


-----------------------------------
you could just set the current color to the color to whatever color you want, and then use a put statement to output your text.  The way you could do this is:

color (red)
put "Hi"


or if you're using Font module, then when you go to draw a String, you can set the color in the parameters.

var f : int
f := Font.New ("serif:12")
Font.Draw ("Hi", 1,1,f,red)

-----------------------------------
Jenkinz
Mon Apr 03, 2006 5:15 pm


-----------------------------------
but i thought you had to use numbers in order to declare what color you want to use, not the name

-----------------------------------
HellblazerX
Mon Apr 03, 2006 5:18 pm


-----------------------------------
you can use names as well, but they're only predefined for the first 15 or so colors.  Simple colors like red, blue, black, gray, but after 15, you gotta use the numbers.

-----------------------------------
Tony
Mon Apr 03, 2006 5:22 pm


-----------------------------------
but i thought you had to use numbers in order to declare what color you want to use
that is correct.

"names" such as red, blue, black are constants that represent the said number. Try it out

put red
put blue

If you're using Turing 4.x editor, the constants should be colour-coded appropriately (constant black, instead of variable blue)

-----------------------------------
Jenkinz
Mon Apr 03, 2006 9:16 pm


-----------------------------------
so 

put "red"
put "blue
or
put red
put blue

and if i do that it will make the word blue blue and the word red red, sorry if i seem to be rambling my esxams tomorow lol

-----------------------------------
Martin
Mon Apr 03, 2006 9:48 pm


-----------------------------------

put blue
put "blue"
color(red)
put "red"
put "Also red!"
color(blue)
put "blue"
color(5)
put "color!"


results in:

1 (I think - some number in any case)
blue (coloured black)
red (coloured red)
Also red! (coloured red)
blue (coloured blue)
color! (in whatever color 5 is)


Experiment with this code and you should figure it out no problem.

-----------------------------------
Delos
Mon Apr 03, 2006 9:51 pm


-----------------------------------
No...that's not quite what Tony meant.

- to change the colour of text, use the colour (colourNum : int) command.  e.g.:

put "Hello"..
colour (12)
put " World!"


- certain keywords such as 'blue' and 'black' are infact constants representing numbers that are equivalent to colour references.  i.e.:

colour (black)
% is the same as:
colour (7)


Good luck with your exam.

-----------------------------------
Jenkinz
Mon Apr 03, 2006 9:56 pm


-----------------------------------
but what if it put,

color (red)
put "Hello World!"

won't all teh text after this command appear red, or do i have to issue a stop command after Hello world of some sorT?

-----------------------------------
[Gandalf]
Mon Apr 03, 2006 10:10 pm


-----------------------------------
Yes, all the text after it made using put will be red from then on.  To eliminate this, you would just reset the colour:
colour(red)
put "Hallo."
colour(black)
put "Auf wiedersehen."

-----------------------------------
Jenkinz
Mon Apr 03, 2006 10:19 pm


-----------------------------------
Gandalf, and everoyne who helped me out thanks alot im goign to bed to get some sleep now, i appreciate it all and ill come back when i get my mark on the practical!
