using "receive" within a codebox
I have a codebox with a gen object that uses a lot of values
Rather than having an enormous # of inputs, I'd like to just send/receive the values.
I have all the sends set up.
In my codebox I have code like this:
tapLevelModX = receive("tapLevelModX");
It seems to compile ok and gets turned into this:
tapLevelModX = receive();
However in the parent object where the gen~ object is declared, I am getting:
gen~: 890:62:cast to '_object *' from smaller integer type 'long'
gen~: 3923:28:use of undeclared identifier 'receive'
gen~: 3924:28:use of undeclared identifier 'receive'
gen~: 3925:34:use of undeclared identifier 'receive'
gen~: 3926:34:use of undeclared identifier 'receive'
gen~: 3927:34:use of undeclared identifier 'receive'
gen~: 3928:40:use of undeclared identifier 'receive'
gen~: 3929:28:use of undeclared identifier 'receive'
gen~: 3930:28:use of undeclared identifier 'receive'
gen~: 3931:34:use of undeclared identifier 'receive'
gen~: failed to compile patcher
Any help would be appreciated.
Send/receive inside gen only work inside gen. If you have a [send myvalue] inside of your main patch, a [receive myvalue] in your gen~ patch won't receive anything.
This said, instead of using one input for each of your values, you can declare parameters. For example in your case you could have Param tapLevelModX(0);
at the top of your gen codebox (0 being th default value), and send your tapLevelModX value to your gen patch by prepending the parameter name to it. And use the same inlet for all of your parameters (that you need to declare as such).
You could do that even without patch cord using the new param_connect attribute available for UI objects:
Hi, I apologize if I did not make myself clear.
All of the values I am using already exist in the gen patch. I am just trying to find an effective way to send a lot of them to a codebox in the same gen patch. It would not make any sense to treat them as params, since again, they are already values in the gen patch.
The only reason I mentioned the parent item is because that is where I am seeing the error.
An example patch would have helped to better grasp the issue from the beginning!
I don't know if it's the expected behavior (the codebox could be kind of a gen subpatcher in its own, which would explain why the receives don't work. As the doc says "The send/receive pairs are only visible to each other within the same gen patcher. They will not send across gen patchers or sub-patchers.") or if it's bug!
for anyone following this, I gave up on the send/receive method and ended up just creating a data object where values get poked into and my codebox can peek them.
Works fine