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

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




PostPosted: Thu Feb 16, 2006 10:42 am   Post subject: Color String Help

Hey everyone,
I am a high school noob, lol, which having some trouble with turing.
I made this script to allow the creation of a smiley face but I need the user to be able to place the colours they want, say blue, yellow, orange, etc. into the code. BUT it seems that I can only use integers and not strings.

Can you please help me change the fill and face from int to strings?
(btw, its not a simple as just switching the int to string, it will not allow it in the drawfilloval's or drawarc's.)

code:
const centerx:=maxx div 2
const centery:=maxy div 2
const dotx1:=centerx-3
const doty1:=centery+3
const doty2:=centery+3
const dotx2:=centerx+3
const arcy:=centery-1
var xRadius, yRadius: int:=9
var xRadius_eye, yRadius_eye: int:=1
var xRadius_arc, yRadius_arc: int:=5
var fill: int
var face: int

put "Please enter the fill colour for your smiley"
get fill
put "Now, enter the colour of the facial features"
get face

drawfilloval(centerx, centery, xRadius, yRadius, fill)
drawoval(centerx, centery, xRadius, yRadius, face)
drawfilloval(dotx1, doty1, xRadius_eye, yRadius_eye, face)
drawfilloval(dotx2, doty2, xRadius_eye, yRadius_eye, face)
drawarc(centerx, arcy, xRadius_arc, yRadius_arc, 180, 360, face)
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Thu Feb 16, 2006 11:01 am   Post subject: (No subject)

Hello and welcome.
Please indent your code. Press F2 in Turing.

Do you know if clauses yet? This would be the way to go. For instance:
code:

var answer : string
put "How are you?"
get answer

if answer = "fine" then
   put "That's good."
elsif answer = "bad" then
   put "..."
else
   answer := "nothing useful"
   put "You said nothing useful, see:  ", answer
end if


Same sort of idea. Keep in mind that when you type in something like "darkblue" in the IDE (that would be the Turing editor) it is interpreted as a constant. In other words, it's a special word that the interpretter recognizes as meaning a particular integer.
Thus being, entering a string during run-time and trying to pass that off as one of said constants is, well, not possible.
You'll want to get your string input ("blue", "red", etc), check to make sure that it is a valid colour, then use it to assign a variable to the appropriate colour.
Tycoon




PostPosted: Thu Feb 16, 2006 7:00 pm   Post subject: (No subject)

sorry about the indents

I would do that, with all the if's, but where are a lot of colours (1-255)
isn't there someway of having the user type in a basic colour, say red, blue, yellow, or grey, and having it place it in the draw's?
Clayton




PostPosted: Thu Feb 16, 2006 7:31 pm   Post subject: (No subject)

they only have about 15 different colors assigned to actual words, so you can have an if for each of them, the brilliant *snicker* creators of Turing didnt assign a word for every color number, alot less ifs, if your having trouble you should check the Turing Walkthrough, a very valuable source of information and programming tips
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  [ 4 Posts ]
Jump to:   


Style:  
Search: