Replacing part of a list juncto the Empty Message Issue.
THE OBJECTIVE:
Replace a list segment with another one.
BACKGROUND:
Working in Max 8.5.7 (my old iMac can’t handle higher).
So no fancy string objects…
This all comes from the need to change a series of bytes in a sysex message contained in a coll without changing the others.
Tried nsub, but that handles only one byte at a time and puts a fatal drag on everything else going on.
So I thought it might speed things up if I split the entire line into head, body and tail, replace the body, put everything together again and store it back to the coll.
I connected two zl.slice objects so that the head comes out the left outlet of the first one, the body out of the left of the second one and the tail out of its righty.
The first slice is made at the insertion point, the second one, now headless, at the length of the list to insert.
THE ISSUE:
When the insertion point is at the start of the list (position 1), the first slice [zl.slice 1] outputs the first element as the head and not as the first element of the body.
So subtract 1 from the position; then [zl.slice 0] outputs the entire list at right for the second cut.
But nothing on the left. Nothing on the left!
Yes, it is the old Empty Message problem again!
Since the head goes into the hot inlet of the join, there won’t be any joining.
SOLUTION:
Preload the zl.regs holding the head and the tail with a null character using itoa, then bang them when processing is complete. If zl.slice did not output anything, the null will be output instead and trigger the join anyway without affecting the list.
Still have to see whether it is indeed faster than nsubbing the coll and if that solves the underlying issue, which I won’t get into here.
I have wrestled enough with the Emtpy Message Issue (EMI) to know I’m not the only one, so here’s one solution. But if anyone can come up with a more efficient approach to replacing part of a list? I have this nagging feeling I'm missing something.
Note: a tosymbol-fromsymbol pair will get rid of the null.
zl.rot ...................................
for sysex which is itered out anyway, one can remove thresh
