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

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




PostPosted: Fri Sep 19, 2003 6:54 pm   Post subject: Font.Draw and variables...

is it possible to use variables in using Font.Draw, example below, ebcause what i've done so far here i can't get to work Confused

code:

var name:string
var FontID : int := Font.New ("Arial:12:bold")
Font.Draw ("Please Enter your name...", 0, maxy-20, FontID, green)
locate (3,1)
get name
put "Thanks"
delay (500)
cls
Font.Draw ("Shall we begin " ,name, "?", maxx div 2, maxy div 2 , FontID, green)
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Sep 19, 2003 7:02 pm   Post subject: (No subject)

you cant use maxx div 2 as an integer value. Any div operation results in a double (real) value. You'd have to round it
code:

round(maxx div 2)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mazer




PostPosted: Fri Sep 19, 2003 7:26 pm   Post subject: (No subject)

tony wrote:
you cant use maxx div 2 as an integer value. Any div operation results in a double (real) value. You'd have to round it
code:

round(maxx div 2)


wha??! Eh
using div will divide and truncate. therefore integer div integer will give yet another integer; no rounding necessary!
Tony




PostPosted: Fri Sep 19, 2003 7:30 pm   Post subject: (No subject)

Mazer wrote:

wha??! Eh
using div will divide and truncate. therefore integer div integer will give yet another integer; no rounding necessary!


ops, my bad... didnt use Turing in a long while..

anyways, in the line
Quote:
"Shall we begin " ,name, "?",


it doesnt work the same way was put does. See those commas? It actually things that the variable name is the next argument for the function, so it gets confused. You should use + sign instead to add strings together.

code:

"Shall we begin " + name + "?"
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
BryX




PostPosted: Fri Sep 19, 2003 7:30 pm   Post subject: (No subject)

thx alot man
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  [ 5 Posts ]
Jump to:   


Style:  
Search: