Menu

#244 member offset in macro

open
v1ctor
compiler (117)
2012-10-10
2012-04-24
c Rex
No

I'd like to be able to do stuff like in the commented out section

------------- code start ------------------
dim shared as integer shared_y = 50

dim as integer UB = 99

dim as single Ary(UB)

Function F(ByVal in_ as single) as double
return Rnd - 0.5
End Function

macro mac( ret, pos_, increm, pFunc )

ret = pFunc(pos_)
pos_ += increm

EndMacro

Macro macWave( out_, angle_, iAngle_, pFunc )

For I as integer = 0 to UB
mac(out_, angle_, iAngle_, pFunc)
PSet (I, out_ * 10 + shared_y), 15
Next
shared_y += 30

EndMacro

ScreenRes 640, 480

Dim As single a, angle, iAngle = 0.1
macWave(a, angle, iAngle, sin)
macWave(a, angle, iAngle, F)
macWave(a, angle, iAngle, Ary)

/'
Type sampLR
as single L
as single R
End Type
Dim as sampLR LUT_LR()
macWave(a, angle, iAngle, LUT_LR.R)
'/
------------ code end ----------

Discussion

  • fxm (freebasic.net)

    I do not agree with this request because the right syntax is:
    a = LUT_LR(angle).R
    and not:
    a = LUT_LR.R(angle)

    and in addition, the dynamic array LUT_LR() is not sized before use.

     
  • c Rex

    c Rex - 2012-04-24

    forgot the dim variable.

    Dim as sampLR LUT_LR(UB)

    I thought first that I could go
    macWave(a, angle, iAngle, LUT_LR().R)

    but I know that in macro parms, I normally don't need an () on array

     

Log in to post a comment.