Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 color text
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jenkinz




PostPosted: Mon Apr 03, 2006 4:58 pm   Post subject: 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!
Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Mon Apr 03, 2006 5:10 pm   Post subject: (No subject)

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:

code:
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.

code:
var f : int
f := Font.New ("serif:12")
Font.Draw ("Hi", 1,1,f,red)
Jenkinz




PostPosted: Mon Apr 03, 2006 5:15 pm   Post subject: (No subject)

but i thought you had to use numbers in order to declare what color you want to use, not the name
HellblazerX




PostPosted: Mon Apr 03, 2006 5:18 pm   Post subject: (No subject)

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




PostPosted: Mon Apr 03, 2006 5:22 pm   Post subject: (No subject)

Jenkinz wrote:
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
code:

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)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jenkinz




PostPosted: Mon Apr 03, 2006 9:16 pm   Post subject: (No subject)

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




PostPosted: Mon Apr 03, 2006 9:48 pm   Post subject: (No subject)

code:

put blue
put "blue"
color(red)
put "red"
put "Also red!"
color(blue)
put "blue"
color(5)
put "color!"


results in:
code:

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




PostPosted: Mon Apr 03, 2006 9:51 pm   Post subject: (No subject)

No...that's not quite what Tony meant.

- to change the colour of text, use the colour (colourNum : int) command. e.g.:
code:

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.:
code:

colour (black)
% is the same as:
colour (7)


Good luck with your exam.
Sponsor
Sponsor
Sponsor
sponsor
Jenkinz




PostPosted: Mon Apr 03, 2006 9:56 pm   Post subject: (No subject)

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]




PostPosted: Mon Apr 03, 2006 10:10 pm   Post subject: (No subject)

Yes, all the text after it made using put will be red from then on. To eliminate this, you would just reset the colour:
code:
colour(red)
put "Hallo."
colour(black)
put "Auf wiedersehen."
Jenkinz




PostPosted: Mon Apr 03, 2006 10:19 pm   Post subject: (No subject)

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!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: