Return value from Var must be matching type

BlitzMax Forums/BlitzMax Beginners Area/Return value from Var must be matching type

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Dreamora. No, it shouldn't work. When you cast a variable like int(somefloat#), it's not the variable being converted, but rather the value inside the variable. You can't create a reference to that value since the value isn't stored anywhere.
Now if you were to do
local SomeInt:Int = Int(SomeFloat)
Local SomePtr:Int Ptr = Varptr SomeInt

That would work because now the converted value is being stored somewhere that can be referenced.
Some languages, such as c++, do allow you to cast pointers of one type to pointers of another. For instance
Float *Float_ptr;

DoSomething((int *)Float_ptr);

However, if the function DoSomething writes to the area pointed to, it will be as an Int and not a Float. The results will be corrupted. Typically type pointers will be cast when a function deals with the raw data and not with actual values.