Integer to String conversion
Author |
Message |
Asok
|
Posted: 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
|
|
|
CyCLoBoT
|
Posted: Tue Feb 25, 2003 12:36 pm Post subject: (No subject) |
|
|
why don't u leave all your variables to be integers? |
|
|
|
|
|
Asok
|
Posted: 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
|
Posted: 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
|
Posted: 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! |
|
|
|
|
|
|
|