You can only seem to return a single element in a UDT from a function not a whole UDT.
Passing UDT's to functions works fine as in the example below
sync on : sync rate 60
type xyLoc
x as integer
y as integer
endtype
Point1 as xyLoc
Point2 as xyLoc
global midPoint as xyLoc
Point1.x=50
Point1.y=300
Point2.x=200
Point2.y=100
calcMidPoint(Point1,Point2)
print str$(midPoint.x)+","+str$(midPoint.y)
sync : sync : suspend for key
end
function calcMidPoint(In1 as xyLoc,In2 as xyLoc)
if In1.x < In2.x
midPoint.x=In2.x-In1.x
else
midPoint.x=In1.x-In2.x
endif
if In1.y < In2.y
midPoint.y=In2.y-In1.y
else
midPoint.y=In1.y-In2.y
endif
endfunction
But can't return a whole UDT. If someone would like to demonstrate how to return the midPoint UDT in the example back from the function in one call then, rather than having to pass back to a global variable I'll be convinced it works
Seems only to be 50% of the way there to me at the moment
The coder formerly known as Twynklet.