Help on custom module

Hello, I need some light to better understand how the custom module works and specifically the port addresses filtering.
I have an OSC patch that allows me to manage midi track articulations and display GUI interfaces depending on the tracks (plugin) selected in Cubase.
The track controllers are sent to the custom module on DAWtoOSC port, ch 1 ctrl 116 to 127, the GUI controllers are sent on midictrl port ch 1 to 16 on all controllers via generic remote in cubase.
My problem: there is obviously a conflict between the ports on ctrl 116 to 127 between DAWtoOSC and midictrl, the display works but always jumps to the last case. the solution I found is to release the GUI ctrl 116 to 127 from the generic remote and route them to other ch/ctrl.
I'm sure there is probably a better solution in the custom modul but I can't find it.
here a sample of my probleme :

 module.exports = {  
    var {address, args, host, port} = data
    if (address !=='/control') return {address, args, host, port}
	if (args[1].value < 115) return {address, args, host, port}
	if (args[1].value == 127) 
		{send('midi','OSCtoDAW','/control', 1,126,1)
	    return {address, args, host, port}}

else if (args[1].value == 116 && args[2].value == 4)
    receive('/EDIT', 'Quick controls', {html:'Absynth'});
    receive('/EDIT', 'Quick controls',{
    widgets: [...]})return }
    /// other GUI case here... and the last
else if(args[1].value>=117)
        bank = (args[1].value - 117)     
		patch = (bank * 128) + args[2].value;
		labelTexts = instruments[patch].trackarticulations
		var len = labelTexts.length
		for (i = 0; i < len; i++)
			receive(Object.values(buttons)[i], {type:'i', value: 1})
			receive(Object.values(labels)[i], {type:'s', value: labelTexts[i]})
			for(z of colors){
				for(y of colortrack[z]){
					if(labelTexts[i] == y) {
						var colorcode = z
						receive(Object.values(labelscolor)[i], colorcode);}}}}
  receive('/EDIT', 'Quick controls', {html:'Kontakt - '+ instruments[patch].trackname})
  receive('/EDIT', 'Quick controls',{
           widgets: [...]})
	    return } return {address, args, host, port}},}

Otherwise, I have two other small questions:

How to make the content of a modal adjusted to the content?
I can hide/show a tab from the custom module with receive('/Tab1/visible',1); but what is the syntax to make a tab active from the custom module?


Is "midictrl" another midi port declared in O-S-C's midi config (like "DAWtoOSC") ? If so you can determine the origin of incoming messages using data.port.

How to make the content of a modal adjusted to the content?

That's not supported.

what is the syntax to make a tab active from the custom module?

Activating a tab is done simply by sending a value to its parent: the value of tab containers determine the index of the active tab, starting with 0. Alternatively, there's the /TABS command.

Yes, my config : OSCtoDAW:-1,0 DAWtoOSC:1,-1 midictrl:virtual
You mean something like
if (args[1].value == 116 && args[2].value == 1 && data.port == 'DAWtoOSC' )?

I will try

Yes. data.port is assigned to port here:

var {address, args, host, port} = data

I prefer filtering based on port before anything else:

if (port === "A") {
  // conditions for port A
} else if (port === "B") {
  // conditions for port B

Since you're on mac (I assume, because you're using cubase and o-s-c virtual ports), why not use a single virtual port instead of OSCtoDAW and DAWtoOSC ?

Thank you, this is exactly what I needed.
You're right, I'm on mac and the use of the two ports OSCtoDAW and DAWtoOSC is the legacy of the original template I used at the beginning, I need to clean that up.
My own template is almost finished and I'm trying to unify and simplify things but there are so many possibilities with OSC that it takes a little time!
Thanks again for this great software

Thank you :slight_smile: