Computer Science Canada

Integer variable in Font.Draw

Author:  Jas [ Wed Apr 06, 2005 7:37 pm ]
Post subject:  Integer variable in Font.Draw

code:

var num : int
get num
var font2 : int := (Font.New ("Times New Roman:15:bold,"))
Font.Draw (num, 300,250,font2,white)
Font.Free (font2)


In the above program, i get an error that says "argument is the wrong type" in the Font.Draw line at the "num" variable.

This is probably because you cant have a variable that is an integer in that position. If i assign num as a string, and the user inputs an integer, it works. But i cant do that because the rest of my program involves that variable(in for loops), and it has to be an integer . Is there any way you can make this program work with leaving num as an integer?

Author:  jamonathin [ Wed Apr 06, 2005 7:49 pm ]
Post subject: 

First of all, you only need this for the font
code:

var font :int := Font.New ("Comic Sans MS:10:bold") % or w/e

secondly, use intstr, such as
code:
Font.Draw(intstr(num),10,10,font,2)

you can also set another variable to the string value of the number, juss do this
code:
var fart :string := intstr(num)


I'm sure there's tutorials on this somewhere, juss look around.


: