[Implemented] This would allow Procedures more versatile
Posted: Wed Feb 13, 2008 5:20 pm
Let me explain with this example:
I have this nice function:As you can see, the function gets an array (PointList.f(2)) which is a table containing a total of 4 2D coordenates.
In order to call to that function this can be done:or also.
The fact is that the array is passed by reference (and the same happens when passing a linked list), i.e. we are indeed passing a pointer.
Well, if i have the table in a DataSection (i.e. pointed by a label) or in general in a '*pointer' variable, then i can not use that function, but another like this:, which does not allow the array passing.
Making possible the call with any kind of pointer (not just an array or linkedlist pointer), the function is much more versatile.
I have this nice function:
Code: Select all
Procedure BezierCubicLine(PointList.f(2),res.f=0.02)
Protected t0.f=0.0,t1.f=1.0,bx0.f=PointList(3,0),by0.f=PointList(3,1),bx.f,by.f
t0.f+res:t1.f-res
While t1.f>=0
bx.f=PointList(0,0)*t0*t0*t0+3*PointList(1,0)*t1*t0*t0+3*PointList(2,0)*t1*t1*t0+PointList(3,0)*t1*t1*t1
by.f=PointList(0,1)*t0*t0*t0+3*PointList(1,1)*t1*t0*t0+3*PointList(2,1)*t1*t1*t0+PointList(3,1)*t1*t1*t1
LineXY(bx0,by0,bx,by)
bx0.f=bx:by0.f=by
t0.f+res:t1.f-res
Wend
EndProcedure
In order to call to that function this can be done:
Code: Select all
Dim Pointsl.f(3,1)
BezierCubicLine(Pointsl.f())
Code: Select all
Dim Pointsl.f(3,1)
BezierCubicLine(@Pointsl.f())
The fact is that the array is passed by reference (and the same happens when passing a linked list), i.e. we are indeed passing a pointer.
Well, if i have the table in a DataSection (i.e. pointed by a label) or in general in a '*pointer' variable, then i can not use that function, but another like this:
Code: Select all
Procedure BezierCubicLine(*PointList.f,res.f=0.02)
Making possible the call with any kind of pointer (not just an array or linkedlist pointer), the function is much more versatile.