Get value from 2nd switch using custom module

I have two switches in my panel, that do not interact directly but I need to use the values from both.

I can collect the value of one switch (called 'TransChordFrom') when it is pressed and use it in my custom module. But I need to also use the value of another switch TransChordTo that is pressed independently.

I want to then use both these values to send to a function getChordModificationLabel

        if (address === '/TransChordFrom') {

            transposeFromValue = args[0].value; //gets value from switch

            chordType = getChordModificationLabel(transposeFromValue, transposeToValue);

        });
            receive('/EDIT', 'modal_transpose_DescribeBtn', { type: 's', value: { 'label': chordType } }); }

        if (address === '/TransChordTo') {

            transposeToValue = args[0].value; //gets value from switch

            chordType = getChordModificationLabel(transposeFromValue, transposeToValue);

        });
            receive('/EDIT', 'modal_transpose_DescribeBtn', { type: 's', value: { 'label': chordType } }); }

Any ideas on how I can get this to work?

I think I have thought of a way - I can use /EDIT to and change the value in a text box called ValueFromTextBox'and then use /GET to read it back in but I don't know the syntax for /GET

       if (address === '/TransChordFrom') {

            transposeFromValue = args[0].value; //gets value from switch

            transposeToValue = receive('/GET', 'ValueFromTextBox', { value: 'textbox Value' }); // //THIS IS THE BIT I DONT KNOW

            console.log("transposeFromValue" + transposeFromValue); // Output: Value of switch pressed
            console.log("transposeToValue" + transposeToValue); // Output: Value collected using /GET

            chordType = getChordModificationLabel(transposeFromValue, transposeToValue);

           // receive('/EDIT', 'modal_transpose_Describe', { type: 's', value: { 'label': labels[transposeInterval] } });
            receive('/EDIT', 'modal_transpose_DescribeBtn', { type: 's', value: { 'label': chordType } });
            receive('/EDIT', 'ChordValueFromStoreText', { value: transposeFromValue });




        }

receive() doesn't not return any value. Collecting the result of a /GET command sent this way can be done asynchronously in the oscOutFilter function.

The code in your first post looks close to something good, just make sure your variables (transposeFromValue, transposeToValue) are declared outside the function's scope so that they persist between calls, and only call receive('/EDIT', 'modal_transpose_DescribeBtn') once instead of twice.

Thanks, was just a simple mistake as you pointed out, my variables were not persisting as I declared them inside the oscOutFilter

For reference here is what I have now got working:

//Variables for Chord Modification Module

var transposeFromValue = 1 // this is the index of the chord array
var transposeToValue = 1 // this is the position within the object in the chord array
var chordType = "Select the chordstructure to move from and to - - Mofification will appear here"

module.exports = {
oscOutFilter: function (data) { 		
        //Transpose from switch pressed

        if (address === '/TransChordFrom') {

            transposeFromValue = args[0].value; //gets value from switch


            console.log("transposeFromValue" + transposeFromValue); // Output: Value of switch pressed
            console.log("transposeToValue" + transposeToValue); // Output: Value of switch pressed

            chordType = getChordModificationLabel(transposeFromValue, transposeToValue);

            //Send Chord Modification to be done as text to the button

            receive('/EDIT', 'modal_transpose_DescribeBtn', { type: 's', value: { 'label': chordType } });

       
        }

        if (address === '/TransChordTo') {

          //  var testThis = receive('/EDIT/GET', 'ChordValueFromStore', { value });
          //  console.log("Have I got this? " + testThis);
            transposeToValue = args[0].value;


            console.log("transposeFromValue" + transposeFromValue); // Output: Value of switch pressed
            console.log("transposeToValue" + transposeToValue); // Output: Value of switch pressed

            chordType = getChordModificationLabel(transposeFromValue, transposeToValue);

            //Send Chord Modification to be done as text to the button

            receive('/EDIT', 'modal_transpose_DescribeBtn', { type: 's', value: { 'label': chordType } });
        }
        function getChordModificationLabel(transposeFromValue, transposeToValue) {

           // console.log("Function is called"); 
          //  console.log("Function transposeFromValue is " + transposeFromValue);
           // console.log("Function transposeToValue is " + transposeToValue); 
            transposeFromValue--; // Adjust to match array index

            if (transposeFromValue + 1 === transposeToValue) {
                return "No Change to Chord will be made"
            }

            const selectedObject = excelChordValues[transposeFromValue];
            if (!selectedObject) {
                return "Invalid transposeFromValue";
            }

            const keys = Object.keys(selectedObject);
            const index = transposeToValue;

           // console.log("Function keys is " + keys);
          // console.log("Function index is " + index);// Output: Value of switch pressed

            if (index < 0 || index >= keys.length) {
                return "Invalid transposeToValue";
            }

            if (transposeFromValue != transposeToValue) {
              //  console.log("Function Value to be returned is " + selectedObject[keys[index]]);
                return selectedObject[keys[index]];

            }

            
        }
}
}