Simple send and receive of OSC

I have a button in Tap mode to send an OSC string to /string1 when pressed with an on value of hello.
Another button in Tap mode to send an OSC string to /string1 when pressed with an on value of bye.

(DEBUG, OSC) Out:  { address: '/string1', args: [ { type: 's', value: 'hello' } ] } To: 127.0.0.1:8000 
(DEBUG, OSC) Out:  { address: '/string1', args: [ { type: 's', value: 'bye' } ] } To: 127.0.0.1:8000

I want to receive the sent value (hello / bye) via OSC into a text widget. What must be done to the text widget to receive the /string1 value and display it? I assume that I set the osc address to /string1 and the value field to OSC{} or similar but just get undefined displayed.

Sorry for the noob question, can anyone please advise?

Hi,

Depending on if your use case is specific, one alternative method is to use variables.

Set the value of the text widget to VAR{textWidgetVar, ""} textWidgetVar is the variable name, and "" is the default value of the variable which we've set to blank.

Then, on one of the tap buttons, in the onValue script property, you can use the setVar method to change the text widget's variable when the tap button value is initialized. Just replace the textWidgetIdHere with the ID of the text widget.

setVar("textWidgetIdHere", "textWidgetVar", "Hello")

Cheers,
DMDComposer

Thanks @DMDComposer for your input, much appreciated - I want the text widget to receive and display anything sent to OSC address /string1 - whether that be from the two buttons that I press or an external source. Your solution sets the variable directly, but I want it to be set by OSC. Can the text widget or variable monitor that address and display the result?

Setting the address to /string1 is the only thing you need to do to make the widget receive messages sent to this address. See General mechanics - Open Stage Control

Thank you @jean-emmanuel that is exactly what I thought but I am struggling with this basic concept and this is my very first interaction with O-S-C... I am able to send OSC to localhost but the text widget receives nothing. Are you able to look at my minimal code?

{
  "createdWith": "Open Stage Control",
  "version": "1.25.0",
  "type": "session",
  "content": {
    "type": "root",
    "lock": false,
    "id": "root",
    "visible": true,
    "interaction": true,
    "comments": "",
    "width": "auto",
    "height": "auto",
    "colorText": "auto",
    "colorWidget": "auto",
    "alphaFillOn": "auto",
    "borderRadius": "auto",
    "padding": "auto",
    "html": "",
    "css": "",
    "colorBg": "auto",
    "layout": "default",
    "justify": "start",
    "gridTemplate": "",
    "contain": true,
    "scroll": true,
    "innerPadding": true,
    "tabsPosition": "top",
    "hideMenu": false,
    "variables": "@{parent.variables}",
    "traversing": false,
    "value": "",
    "default": "",
    "linkId": "",
    "address": "auto",
    "preArgs": "",
    "typeTags": "",
    "decimals": 2,
    "target": "",
    "ignoreDefaults": false,
    "bypass": false,
    "onCreate": "",
    "onValue": "",
    "widgets": [
      {
        "type": "button",
        "top": 100,
        "left": 100,
        "lock": false,
        "id": "button_1",
        "visible": true,
        "interaction": true,
        "comments": "",
        "width": "auto",
        "height": "auto",
        "expand": "false",
        "colorText": "auto",
        "colorWidget": "auto",
        "colorStroke": "auto",
        "colorFill": "auto",
        "alphaStroke": "auto",
        "alphaFillOff": "auto",
        "alphaFillOn": "auto",
        "lineWidth": "auto",
        "borderRadius": "auto",
        "padding": "auto",
        "html": "",
        "css": "",
        "colorTextOn": "auto",
        "label": "auto",
        "vertical": false,
        "wrap": false,
        "on": "hello",
        "off": null,
        "mode": "tap",
        "doubleTap": false,
        "decoupled": false,
        "value": "",
        "default": "",
        "linkId": "",
        "address": "/string1",
        "preArgs": "",
        "typeTags": "",
        "decimals": 2,
        "target": "",
        "ignoreDefaults": false,
        "bypass": false,
        "onCreate": "",
        "onValue": ""
      },
      {
        "type": "text",
        "top": 150,
        "left": 220,
        "lock": false,
        "id": "textarea_1",
        "visible": true,
        "comments": "",
        "width": "auto",
        "height": "auto",
        "expand": "false",
        "colorText": "auto",
        "colorWidget": "auto",
        "colorStroke": "auto",
        "colorFill": "auto",
        "alphaStroke": "auto",
        "alphaFillOff": "auto",
        "alphaFillOn": "auto",
        "lineWidth": "auto",
        "borderRadius": "auto",
        "padding": "auto",
        "html": "",
        "css": "",
        "value": "",
        "default": "",
        "linkId": "",
        "address": "/string1",
        "preArgs": "",
        "decimals": 2,
        "target": "",
        "onCreate": "",
        "onValue": "",
        "vertical": false,
        "wrap": false,
        "align": "center"
      },
      {
        "type": "button",
        "top": 180,
        "left": 100,
        "lock": false,
        "id": "button_2",
        "visible": true,
        "interaction": true,
        "comments": "",
        "width": "auto",
        "height": "auto",
        "expand": "false",
        "colorText": "auto",
        "colorWidget": "auto",
        "colorStroke": "auto",
        "colorFill": "auto",
        "alphaStroke": "auto",
        "alphaFillOff": "auto",
        "alphaFillOn": "auto",
        "lineWidth": "auto",
        "borderRadius": "auto",
        "padding": "auto",
        "html": "",
        "css": "",
        "colorTextOn": "auto",
        "label": "auto",
        "vertical": false,
        "wrap": false,
        "on": "bye",
        "off": null,
        "mode": "tap",
        "doubleTap": false,
        "decoupled": false,
        "value": "",
        "default": "",
        "linkId": "",
        "address": "/string1",
        "preArgs": "",
        "typeTags": "",
        "decimals": 2,
        "target": "",
        "ignoreDefaults": false,
        "bypass": false,
        "onCreate": "",
        "onValue": ""
      }
    ],
    "tabs": []
  }
}

Sorry, but as a new user, I cannot upload attachments.

Maybe the problem here is that you're attempting to display a value that's being sent out of o-s-c, not received by it (unless there is a message being sent back in response). If you want to display the value sent by these two buttons you don't want to listen for an osc message, there are dedicated mechanics for this (described under "Widget synchronization" in the same page I linked earlier ). In this case, either use the linkId (button's to > myid, text's to < myid, so that the buttons only sends and the text only receives), or scripting (button's onValue):

set('text_id', value)