Cabbage Logo
Back to Cabbage Site

Opcode with optional parameters?

I’m working on an opcode that potentially will have dozens of parameters. Typically, those will mostly take default values. Is there a way to simplify the call to the opcode so that it assumes the default values unless I explicitly assign them? Is there a standard way that folks handle this?

From a programming perspective, I don’t want each call to the opcode to require dozens of values/variables to be in the instrument if most are defaults. That seems like it will be error prone and hard to look at.

Thank you!

EDIT - I’m almost seeing it with the j, O, P, V, J, o, and p inputs, but I’m not sure about the syntax for calling. An example would be really helpful!

As far as I know UDOs can’t have an optional list of inputs, even though native opcodes can. You can overload the UDO, i.e,

opcode MyOpcode, aa, kk
(...)
endop

opcode MyOpcode, aa, kkk
(...)
endop

opcode MyOpcode, aa, kkkk
(...)
endop

I know it’s a little cumbersome, but in the end should help you achieve your goal.