Send a MIDI message without user interaction (using a custom module)

// store digits
                DIGITS[digit] = val
                // then do anything you need with DIGIT

                // for example
                var first3Digits = DIGITS.slice(0,3).join('')
                // I've added this line so that the bar number gets changed to a number that doesn't have a dot and zeros at the beginning
                var cleanedVal = parseInt(first3Digits.replace(/\./g,""))
                if (data.args[1].value === 71) console.log(cleanedVal)
                return
GIF

bad reply on every new ten

Can you give me a hint on why is this happening? (see the GIF)
Also, you've said that I don't need to access the GUI in order to get the value of the digit widgets.
But what if at some point I need to get a value from the GUI? Will I be able to get it? Again, without user interaction.

I'm currently studying this post, but I'm afraid that the method you described there requires user interaction...

Sorry I'm asking so many questions! Thank you.

EDIT
It's ok if there's no solution (or you don't have the time to suggest one).
If you'd like, I'll post my workaround code (the "wings" are not where they are supposed to be, but... I've brought the functionality to a satisfying degree – more or less anyway!).