Call multiple instances of UDOs in a Loop?

I have written a small UDO that is a delayline to build an FDN Reverb implementation that is a little bit more flexible than writing each delayline by hand. But I don’t understand how to achieve what I want to do.

Inside of my Instrument I wrote this:

  indx = 0
  afil[indx] = delayline(a1, idelTime[indx], kpitchmod, kgain, ktone, afil[indx], apj, indx)
  looplt indx, 1, iamountOfDelayLines, loop

And don’t understand why it is not equivalent to this:

  afil[0] = delayline(a1, idelTime[0], kpitchmod, kgain, ktone, afil[0], apj, 0)
  afil[1] = delayline(a1, idelTime[1], kpitchmod, kgain, ktone, afil[1], apj, 1)
  afil[2] = delayline(a1, idelTime[2], kpitchmod, kgain, ktone, afil[2], apj, 2)
  ;... and so on until i = iamountofDelayLines

The behaviour I get with the first snippet is that only the last delay line is doing something and all other indices of the array stay empty, in the second snippet everything is great!

My question is: How can I get the behaviour of the second snippet, without writing every line by hand?

i think you must use recursion here. perhaps you can have a look at

i think it is explained better in the springer csound book (2017). the
examples are here: GitHub - csound/book: Examples and materials for the Csound: A Sound and Music Computing System book

Without seeing the delayline code, you might need a krate loop rather than init-time loop (i.e. change indx to kndx) so that it performs the loop every time it renders a frame of audio.