Type Conversion

BlitzMax Forums/BlitzMax Beginners Area/Type Conversion

Rambo_Bill(Posted 2005) [#1]
Whats the syntax? I'm getting an error when trying to add a float to an int.
this is the closest to an understandable error I've gotten. BOB[A].X is a float, the width is an integer.

If Int [BOB[A].X]+BOB[A].Width<0 Then BOB[A].X = GraphicsWidth()


Perturbatio(Posted 2005) [#2]
Framework BRL.Blitz
Import BRL.StandardIO
Local a:Int = 5
Local b:Float = 10.0
a= a +b
Print a



Rambo_Bill(Posted 2005) [#3]
Okay, I mean explicit conversion, not implicit. Because some times youll want a float to behave as an int. I thought that that would be understood, but appearently I wasn't clear enough for some.


Rambo_Bill(Posted 2005) [#4]
Nevermind, it was a bogus error. Error was somewhere else in the code and now its converting automatically.


Bot Builder(Posted 2005) [#5]
You can convert things like so:

Type P
 Field aField
EndType

Type C extends P
 Field Field2
EndType

MyC:C=new C
MyC.afield=5

Print P(MyC).aField
You don't need to covert it, its just an example.


Rambo_Bill(Posted 2005) [#6]
I'm really sorry for asking this here, but I can't find info. How did you do that black code block? I could really use that for my other post.


Duckstab[o](Posted 2005) [#7]
http://www.blitzbasic.com/faq/faq_entry.php?id=2

Check that out