types question

Archives Forums/BlitzPlus Programming/types question

rdodson41(Posted 2004) [#1]
How do you return a type from a function? I tryied this but it doesnt work. I get an "Illegal Type Conversion" error when compiling.

Type alien
Field x,y
End type


Print a\x
Print a\y

Function randalien()
a.alien=New alien
Return a.alien
End Function

I get the error where the function returns the varible. Is there anyway to return the a.alien that I create in the function to be used in the main program?

Who was John Galt?(Posted 2004) [#2]
Use "Function randalien.alien()"

rdodson41(Posted 2004) [#3]
Thanks Falken!

Who was John Galt?(Posted 2004) [#4]
No worries

WolRon(Posted 2004) [#5]
Function Foo() returns an integer variable
Function Foo#() returns a float variable
Function Foo$() returns a string variable
Function Foo.Atype() returns a variable of type Atype

Regular K(Posted 2004) [#6]
Function Foo%() returns an integer variable also! but its same without the %, its for neat freaks :P I use the % to tell if the function returns an integer at all!