For example, I need a procedure to return to me a point or a location which are having at least two variables (position X and position Y). Sometimes, I need more such as Color, or 3-dimension vector value.
My question is :
Is there any alternative for a procedure to return multiple values
Last edited by SkyManager on Sun Mar 11, 2007 3:57 am, edited 1 time in total.
Structure test
a.l
b.l
EndStructure
Procedure ModifyStruc(*ts.test)
*ts\a=100
EndProcedure
;Dummy data.
x.test
x\a = 1
Debug x\a
;Pass to the procedure.
ModifyStruc(@x) ;@ is the 'address of...' operator.
Debug x\a ;See, the value has changed.
Alternative methods include having the procedure returning a pointer to a newly allocated block of memory etc. However, the calling program then has to take steps to free the memory etc.
I may look like a mule, but I'm not a complete ass.
; Return Multiple Results from Procedure AKJ 02-Mar-07
Procedure.d CircleInfo(radius.d, *area, *circum)
; Return the area and circumference for a circle of given radius
Protected area.d, circ.d
area = #PI*radius*radius: PokeD(*area, area)
circ = 2*#PI*radius: PokeD(*circum, circ)
EndProcedure
; Main program
Define a.d, c.d ; Area and circumference
CircleInfo(5.0, @a, @c)
Debug "Area = "+StrD(a)+" Circumference = "+StrD(c)
End