
-----------------------------------
nmr123321
Tue Jan 24, 2006 9:25 pm

Simple question about fonts
-----------------------------------

var font1 : int
var fontSize : int
for i : 1 .. 25
    font1 := Font.New ("Arial:fontSize:bold")
    Font.Draw ("Hello", maxx div 2, maxy div 2, font1, red)
    delay (100)
    Font.Draw ("Hello", maxx div 2, maxy div 2, font1, white)
    fontSize := fontSize + 1
end for

Is it possible to replace the size in a Font.New statement with a variable?
any help will be appreciated

-----------------------------------
Delos
Tue Jan 24, 2006 9:29 pm


-----------------------------------
Sure it is.  In this case, you've considered 'fontSize' as a string and not a variable.
- "fontSize" vs. fontSize
You'll have to catenate the value of 'fontSize' to the rest of the string.
So, for instance:

var temp : string := "#"
put "a+temp"   %--> a+temp
put "a" + temp %--> a#

See the difference?

- type-casts
Right now, you have fontSize as an int.  To catenate, you have to have all types the same.  You could consider redeclaring fontSize as a string instead, or you could just type-cast it.  E.g.

put 1, " is a number"
put intstr(1) + " is actually a string"

See the difference?  strint() and intstr() are useful, very (simple, acronymical names, too).

Post up your code when you're done so we can see how well you fared.

-----------------------------------
nmr123321
Tue Jan 24, 2006 9:49 pm


-----------------------------------
never seen this before, thanks .But do i put this instr(fontSize)+' outside the font statement. I am getting this error
Bad font size'instr(fontSize)+' in font selection string


var font1 : int
var fontSize : int:=10

for i : 1 .. 10
    
    font1 := Font.New ("Arial:intstr (fontSize)+")
    Font.Draw ("Hello", maxx div 2, maxy div 2, font1, red)
    delay (100)
    Font.Draw ("Hello", maxx div 2, maxy div 2, font1, white)
    fontSize := fontSize + 1
end for



[/code]

-----------------------------------
Clayton
Wed Jan 25, 2006 8:22 am


-----------------------------------
you dont put the + after your intstr(fontSize), you  put that before       instr(fontSize), then close the brackets. see if thats wat your prob is

-----------------------------------
Clayton
Wed Jan 25, 2006 8:23 am


-----------------------------------
also close the quotes befor your variable otherwise turing wont recognize fontSize as a variable
