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

Username:   Password: 
 RegisterRegister   
 Font.Draw with variables!?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Unicornzrcool




PostPosted: Sun Jan 11, 2009 10:43 pm   Post subject: Font.Draw with variables!?

Hi, I'm rather new at Turing and I was just wondering if it is possible to put a variable within the font.draw, and if it isnt, I would also like to know if there is any way of outputting a variable in a specified font and size.

Turing:
var name1:string
     put "What is your name?"
     get name1
     var font1 : int
     font1 := Font.New ("Comicsans:14:bold,italic")
     Font.Draw ("Welcome   ", 10, 10, font1, black)
                          ^



I would like the variable name1 to come right after the text.

If this is possible I would greatly appreciate it if you could teach me how. =]

Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
Laplace's Demon




PostPosted: Sun Jan 11, 2009 10:47 pm   Post subject: Re: Font.Draw with variables!?

Yes, you can use a variable, you can even use a variable that is not in "string" form, you can also use multiple variables and a mixture of variables and strings using the + sign.

ie: Draw.Text (intstr (health) + " /160", 175, 321, font1, black)


In your case, just alter the line of code to look like: Font.Draw ("Welcome " + name1, 10, 10, font1, black)
andrew.




PostPosted: Mon Jan 12, 2009 4:19 pm   Post subject: RE:Font.Draw with variables!?

Try using the "+" sign to concatenate different strings and variables. Concatenation is when you join two strings together. You can use this in put statements like:
code:
put "Hello " + name


Or, you can use this in your case with:
code:
Font.Draw ("Hello " + name1, 10, 10, font1, black)
Unicornzrcool




PostPosted: Mon Jan 12, 2009 4:47 pm   Post subject: Re: Font.Draw with variables!?

Thank you so much!
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: