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

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




PostPosted: Tue Feb 25, 2003 12:27 pm   Post subject: Integer to String conversion

The following is a code sample of a score board. The challenge is getting string variables "currentscore and topscore" to accept intergers such as "currentscore := currentscore + scoreadded" (scoreadded being an integer variable so type problems occur.)

code:
setscreen ("graphics:640;480")
var player : string := "Player 1"
var currentscore : string := "0000000"
var topscore : string := "0000000"
var font1 : int
font1 := Font.New ("Fixedsys:12")
Font.Draw (player, 50, 470, font1, black)
Font.Draw (currentscore, 53, 450, font1, black)
Font.Draw ("Top Score", 450, 470, font1, black)
Font.Draw (topscore, 458, 450, font1, black)


Any help would be greatly appreciated.
Sponsor
Sponsor
Sponsor
sponsor
CyCLoBoT




PostPosted: Tue Feb 25, 2003 12:36 pm   Post subject: (No subject)

why don't u leave all your variables to be integers?
Asok




PostPosted: Tue Feb 25, 2003 1:17 pm   Post subject: (No subject)

because Font.Draw will only accept strings. So at some point I need to turn the integer into a string.
Dan




PostPosted: Tue Feb 25, 2003 1:46 pm   Post subject: strint

try strint() and/or intstr()

code:

var topscore:int := 1000
var font1 : int
font1 := Font.New ("Fixedsys:12")

Font.Draw (intstr(topscore), 0, 0, font1, black)
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Asok




PostPosted: Tue Feb 25, 2003 2:13 pm   Post subject: (No subject)

intstr works!

*bows* all hail Dan!

Dan thank you so much, you've cleared a problem I've been struggling with for almost a month!
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: