Passing Data / Buffer at Gen~ function
Hi guys,
Is there a way to pass a "Data" name as a parameter on a declared function in gen~'s codebox?
I want to have a function alter some values in various Data arrays, is it possible without hardcoding the Data names in my algorithm?
Nick
Should be possible. Quick test, and it does work, though it did turn up a minor bug (now logged internally):
fun(dat, val) {
poke(dat, val);
// minor bug: a return value is necessary, or else the function might be wrongly optimized away
return val;
}
Data a(1);
Data b(1);
out1 = peek(a, 0);
out2 = peek(b, 0);
fun(a, 7);
fun(b, 4);
Just don't try returning Data/Buffer etc. from a function -- that isn't supported (yet).
Max Patch
Copy patch and select New From Clipboard in Max.
Thank you Graham,
didn't think it would be that simple!
Cheers!
Nick