Get console's text

Hi everyone,

I currently have a custom module (my very first custom module :tada:) which is reading a text file:

var fs = nativeRequire('fs')

module.exports = {


    oscOutFilter:function(data){
        // Filter outgoing osc messages

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

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

        const fs = nativeRequire('fs');

            fs.readFile('/Users/swayrian/Hello.txt', 'utf8', (err, data) => {
            if (err) {
            console.error(err);
            return;
            }
            console.log(data);
            });

            return // bypass original message

        }


        // return data if you want the message to be processed
        return {address, args, host, port}

    }


}

In the console it says Hello when I press a button which is set to the address /Hello but how can I then send back that Hello text into a text widget ?

So my goal would be to press a button on OSC which would read a text file and then send the content back to OSC on a text widget.

Congratz on your first custom module !

To send a message to a widget, you'd call receive to simulate an incoming osc message and pass the widget's address to chose it as receiver:

var text = 'Hello'
receive('/text_widget_address', text)
// if the widget has preArgs you'll need to insert those:
receive('/text_widget_address', preArg1, preArg2, text)
1 Like

That's awesome, thank you very much @jean-emmanuel !

It's been a long journey to arrive at this stage and I'm starting to see the potential of using a custom module. I still have to learn and understand more than 90% of the basics but at the end of the day it's all good fun :smile: