Returning a type object
BlitzPlus Forums/BlitzPlus Programming/Returning a type object| 
 | ||
| I need my function to return a type object. Like this: Type thing Field number End Type While Not KeyDown (1) For t=0 To 10 box.thing=New thing box\number=Rand(1,255) Next box.thing=MyFunction() Print Str$(box.thing) Wend Function MyFunction() box.thing=First thing Return box.thing End Function However, no matter what I do, it allways gives me an "Illegal Type Conversion". I've tried changing "Return box.thing" and "box.thing=MyFunction()" to just be box, but that gives me the same error. How should I do this? | 
| 
 | ||
| The answer lies in the thread below yours: http://www.blitzbasic.com/Community/posts.php?topic=86223#976902 | 
| 
 | ||
| That's what I tried, I get an illegal type conversion. | 
| 
 | ||
| Type thing Field number End Type While Not KeyDown (1) For t=0 To 10 box.thing=New thing box\number=Rand(1,255) Next box.thing=MyFunction.thing() Print Str$(box.thing) Wend Function MyFunction.thing() box.thing=First thing Return box.thing End Function that should work | 
| 
 | ||
| Yep, that works. Thanks. |