how to STR$ things?

BlitzMax Forums/BlitzMax Programming/how to STR$ things?

Crinkle(Posted 2010) [#1]
Seriously this must be the most important function ever so why is it not in MAX? :/


JazzieB(Posted 2010) [#2]
Because there doesn't need to be one...
Global a:Int=10
Global str:String=a
Print str

It's automatic.


Crinkle(Posted 2010) [#3]
meh, very unhelpful help file, it makes it sound like STRING can only be used for arrays. and where is LOADFONT gone whilst im here?


jkrankie(Posted 2010) [#4]
LoadImageFont is in max2d

Cheers
Charlie


Crinkle(Posted 2010) [#5]
tragically name function! Sounds like its loading a special font from a bleedin' image file!

but if thats right, then why doesn't this work?

gary=LoadImageFont Arial,18
SetImageFont gary

"unable to convert from 'TImagefont(Object,Int,Int)' to 'Int'"

WTF:s


Warpy(Posted 2010) [#6]
gary:TImageFont=LoadImageFont("c:\windows\fonts\arial.ttf",18)
SetImageFont(gary)

You need to make 'gary' the right type, and you have to use brackets for a function call (you can omit them when the function call is on its own on a line, but many people prefer not to do that because they find it confusing)
Finally, you need to give the full path to the font file.

The documentation isn't great, and BlitzMax is quite a bit different from other BASICs, so just take your time.


zambani(Posted 2010) [#7]
You have to load the actual path to the font not the name

Local font:TImageFont=LoadImageFont("C:\WINDOWS\Fonts\arial.ttf",36)

On windows computer the fonts are usually located in the windows/font folder.

You can always copy that to your game folder if you want.


Crinkle(Posted 2010) [#8]
"TImageFont"! Now why didn't i think of that its glaringly obvious!

/sarcasm.

It would really help if the help was helpful! I should probably do what i did last time and just mess with the example programs untill i figure it out, or just give up! No other alternatives really!


Czar Flavius(Posted 2010) [#9]
Put strict at the start of your program, and make sure you declare all variables of the right type. click a function and press f1 twice and the doc will tell you what type is returned by the function. You can't store types in integer variables anymore.


Ghost Dancer(Posted 2010) [#10]
Its an ImageFont because its part of the Max2D graphics module, and to distinguish it from a GuiFont (part of MaxGui). All types have the prefix "T".

If you are having problems finding the right commands in the docs, I'd recommend using Help File Creator, which creates a searchable front page to the docs. I downloaded ir via Blitz Companion http://www.blitzmax.com/Community/posts.php?topic=79814


Czar Flavius(Posted 2010) [#11]
You can manually convert to a string using String(x). This can be handy for:

Print String(5) + String(7) '57
instead of
Print 5 + 7 ' 12


TomToad(Posted 2010) [#12]
Or you can use a shortcut and do Print 5 + "" + 7


Crinkle(Posted 2010) [#13]
Ok i'm back, maybe i've forgotten something (besides the help files are useless) but why doesn't this work:

temp$=String(ReadLine(file))
DrawText 0,0,temp$


TaskMaster(Posted 2010) [#14]
Is file really a valid TStream? ReadLine returns a string, so you do not need to cast it to string.

Have you started a graphics context?

You will need to show more code to get a definitive answer.


Jesse(Posted 2010) [#15]
Are you sure it's not your syntax? DrawText should be:
DrawText temp$,0,0


press f1 after typing a registerd command and at the bottom of the ide a simple usage instructions will be displayed most of the time.