Computer Science Canada

Font.Draw with variables!?

Author:  Unicornzrcool [ 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]

Author:  Laplace's Demon [ 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)

Author:  andrew. [ 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)

Author:  Unicornzrcool [ Mon Jan 12, 2009 4:47 pm ]
Post subject:  Re: Font.Draw with variables!?

Thank you so much!


: