How to reference local RS widget script handle from global rackspace script?

I have some script in the global rackspace that is creating a custom caption of a widget. I want to control this widget from the local rackspace. I connected them via the traditional local to global link and it is controlling the widget, BUT the custom caption is not appearing in the local rackspace widget (obviously). How can I make that caption in the global appear in the local? In the global its a simple SetWidgetLabel line but how do I reference the widget in the local rs in the global rs script?

Alternatively, I would also be happing the text to a label widget in the local rs. Just some way to get the custom caption there.

I’ll respond here instead of that other thread.

I think you’ll need to use OSC_SendStringSpecific instead of OSC_SendString. Here’s the listing from the System Function page.

OSC_SendStringSpecific : Send an OSC message with a value of type String to the specified ip address and port

  • Declaration: function OSC_SendStringSpecific (address : String, value : String, ipAddress : String, port : Integer)

This means using the localhost IP address of 127.0.0.1 and then using the listening port of the instance you’re sending from. So, if your listening port was 15000, it would look like this:

OSC_SendStringSpecific("/lbl", txt, "127.0.0.1", 15000)

I tried it very quickly using the script from the other thread and was able to get the caption from a widget in the Global rackspace over to a widget in the local rackspace this way.

caption

And what is in the local RS script? For the other OSC receiving (yesterday) I had the

On OSCMessageReceived(m : OSCMessage) Matching “/lbl”
txt = OSC_GetArgAsString(m,0)
SetWidgetLabel(lbl,txt)
End

I tried adding the word “Specific” to be

On OSCMessageReceivedSpecific(m : OSCMessage) Matching “/lbl”

but didn’t work with or without. Can you upload a sample gig file of what you just did? Thanks!

Like I said, the only thing that needed to be changed was OSC_SendStringSpecific instead of OSC_SendString– that one line in the script that sends. The rest of both scripts were exactly the same.

When you use OSC_SendString, it sends the message on the send port which you have defined in the OSC Setup page-- but your listening port cannot be the same as the send port in the same instance of GP (bad endless loop). Since you are wanting to send a message within the same instance, you have to use OSC_SendStringSpecific so you can define which port the message is being sent to-- in this case, the listening port of the same instance.

Working nice! Great! Not sure what I did, I thought I had tried both ways, but wasn’t working, now it is. I must have had a typo or something. Thank you! One question though, if I ever change the port number in my main OSC settings, I’ll have to remember to change the code. I guess there is no way to do this without specifying the port number?

As another solution you could do that pretty easily without OSC and without scripts in BOTH the global and local rackspace using this function

SetExternalWidgetLabel (ew : ExternalWidget, newValue : String)

For it to work you need to bind the external widget once (this adds to your local rackspace script):

var
    ew : ExternalWidget

On Activate
    If BindExternalWidget(ew, "widget handle", "GLOBAL RACKSPACE") then
End

Don’t forget to replace the widget handle with your actual widget handle, but leave the quotation marks.

I tried this, but I got an error.

  if stepperValues[index] == 1 then
     SetWidgetLabel(RevDelStepper, "1: Clean" + stepperValues[index])
     SetExternalWidgetLabel (ew : ExternalWidget, newValue : String)

GLOBAL RACKSPACE (Script Entity: GlobalRackspace) - - Syntax Error in “Main”: Line 100, Col 10: Unexpected or unrecognized token: ‘SetExternalWidgetLabel’
Mismatched input ‘SetExternalWidgetLabel’ expecting {End, Else, Elsif}

Error message says it all!

All I did was paste: SetExternalWidgetLabel (ew : ExternalWidget, newValue : String)

Before that I was not getting that error and when I remove it I don’t get that error.

That may be - but it’s very hard to diagnose a script error when you only post a snippet of it!

For example, what is the line following that SetExternalWidgetLabel?

Here is the whole thing:

On WidgetValueChanged(newValue : double) from RevDelStepperif newValue > 0 thenindex = (index + 1) % Size(stepperValues)SetWidgetValue(RevDelStepper, 0)
  if stepperValues[index] == 1 then
     SetWidgetLabel(RevDelStepper, "1: Clean" + stepperValues[index])
     SetExternalWidgetLabel (ew : ExternalWidget, newValue : String)
     LoadGPPreset(ValRev, "1")
     SetWidgetValue(RevGain,0.4)
     LoadGPPreset(ValDel, "1b")
     SetWidgetValue(DelGain,0.25)
     
elsif stepperValues[index] == 2 then
     SetWidgetLabel(RevDelStepper, "2: Crunch" + stepperValues[index])
     SetExternalWidgetLabel (ew : ExternalWidget, newValue : String)
     LoadGPPreset(ValRev, "2")
     SetWidgetValue(RevGain,0.36)
     LoadGPPreset(ValDel, "2-DualDuck")
     SetWidgetValue(DelGain,0.30)
     
elsif stepperValues[index] == 3 then
     SetWidgetLabel(RevDelStepper, "3: Lead" + stepperValues[index])
     SetExternalWidgetLabel (ew : ExternalWidget, newValue : String)
     LoadGPPreset(ValRev, "3")
     SetWidgetValue(RevGain,0.40)
     LoadGPPreset(ValDel, "Lead1")
     SetWidgetValue(DelGain,0.40)
     
elsif stepperValues[index] == 4 then
     SetWidgetLabel(RevDelStepper, "4 Ambient" + stepperValues[index])
     SetExternalWidgetLabel (ew : ExternalWidget, newValue : String)
     LoadGPPreset(ValRev, "4")
     SetWidgetValue(RevGain,0.45)
     LoadGPPreset(ValDel, "Quad-DuckTape")
     SetWidgetValue(DelGain,0.45)
    End
End
End

Thank you for that explanation. Makes perfect sense!

That’s a definition, not an implementation

So first of all, there’s no declaration of “ew” in this script

Secondly

You have to call that function with values

E.g,

SetExternalWidgetLabel(ew, “Here is a value”)

Rule#1: Don’t fix what isn’t broken. :slight_smile:

Touche! But it might be broken in the future if I change the port and I forget to update the code! LOL

Not a likely situation, so its not a big deal, but it “could” happen! :wink:

I’m pretty sure that it will work flawlessly if you add the provided line to your variables so the external widget is declared and the “On Activate” callback so the widget is bound when the rackspace is activated.

And in your callbacks change the function to

and you’re done.

Yeah, I am sure it will work once I put everything in right. I’m confused by what is an external widget depending on which rackspace I’m in. Global or local. So in the global, I am assuming the widget in the local is considered “ExternalWidget”. So that would be the handle of the widget in my local RS. So I declare my local RS handle in the global as an external widget. For example:

Var

Ltest = ExternalWidget

Then in OnWidgetValueChanged (still in the global) I put for example:

SetExternalWidgetLabel (Ltest, “hello”)

Then in the local, in your example you have:

What is the ExternalWidget from the perspective of the local RS? What WAS the ExternalWidget (Ltest) in the global, is not an external within the local script and so if its the same Ltest and I am supposed to add my local widget handle (which is the same thing) is it supposed to read:

On Activate
    If BindExternalWidget(Ltest, "Ltest", "GLOBAL RACKSPACE") then
End

I don’t think so! I’m sure I am the one not understanding it and I am confusing things, but this is where I am stuck.

Depending on which way you want to have the link, there’s always only a script needed on one side. The other side doesn’t need any code except that the widget needs a handle.

I think you were overthinking a little and changed too much. For example “ew” needs to stay as it is and your “Ltest” needs to go where I wrote “widget handle” (see below).

From your first post I understood you had a label in the local rackspace and want a label in the global rackspace to react to that local change.
For this direction you need the code only in the local rackspace. You would integrate this exact entire thing into your local script:

Don’t change anything other than

When I’m saying widget handle I mean the name of the widget that’s located in the external rackspace (in this case the global rackspace).

Please try that and feel free to share what’s (not) working - you’re almost there.
Is the direction correct or would you like it the other way round (like in your last post)?

Yes, it does seem I was way overthinking it! So actually, I want to send the current widget’s caption in the global rackspace to a label in the local. I control a widget in the global from the local rackspace, but that’s just to start the “action”. The “action” happens in the global, which produces different results (captions) and I wanted to reflect these captions in the global back to a label in the local.

In my use case I have a button in the global rs that is running the “stepper” script. Each time you press it, you get a different value. I wanted these values shown in the local rs. So the widgedt in the local is just mapped to the global internally to act as a “remote control” of the tapping, but no processing is done in the local. And then I would like to either change the caption of that button in the local (which seems problematic) or to simply display the values produced in the global script to be shown in the local rs.

So this is the code in the global that produces the values I am looking to send. Here is where I’d like to sandwich the SetExternalWidgetLabel line. I know in its current form its not right, I just wanted you to see it in context.

On WidgetValueChanged(newValue : double) from RevDelStepperif newValue > 0 thenindex = (index + 1) % Size(stepperValues)SetWidgetValue(RevDelStepper, 0) 
 if stepperValues[index] == 1 then
     SetWidgetLabel(RevDelStepper, "1: Clean" + stepperValues[index])
     //txt = GetWidgetLabel(RevDelStepper)
     SetExternalWidgetLabel(ew,"hello")
     LoadGPPreset(ValRev, "1")
     SetWidgetValue(RevGain,0.4)
     LoadGPPreset(ValDel, "1b")
     SetWidgetValue(DelGain,0.25)
     
elsif stepperValues[index] == 2 then
     SetWidgetLabel(RevDelStepper, "2: Crunch" + stepperValues[index])
     //txt = GetWidgetLabel(RevDelStepper)
     SetExternalWidgetLabel(ew,"hello")
     LoadGPPreset(ValRev, "2")
     SetWidgetValue(RevGain,0.36)
     LoadGPPreset(ValDel, "2-DualDuck")
     SetWidgetValue(DelGain,0.30)
     
elsif stepperValues[index] == 3 then
     SetWidgetLabel(RevDelStepper, "3: Lead" + stepperValues[index])
     //txt = GetWidgetLabel(RevDelStepper)
     SetExternalWidgetLabel(ew,"hello")
     LoadGPPreset(ValRev, "3")
     SetWidgetValue(RevGain,0.40)
     LoadGPPreset(ValDel, "Lead1")
     SetWidgetValue(DelGain,0.40)
     
elsif stepperValues[index] == 4 then
     SetWidgetLabel(RevDelStepper, "4 Ambient" + stepperValues[index])
     //txt = GetWidgetLabel(RevDelStepper)
     SetExternalWidgetLabel(ew,"hello")
     LoadGPPreset(ValRev, "4")
     SetWidgetValue(RevGain,0.45)
     LoadGPPreset(ValDel, "Quad-DuckTape")
     SetWidgetValue(DelGain,0.45)
    End
End
End

Basically I’d like to send the stepperValues[index] part. Thank you!

I’m trying to send an instruction to do something in the local rs. That’s why I have it placed as such. But every example I saw (including this one) is in its own “if” query. Confusing…. I feel like I’m about to hit the “Oh yeah, DUH” moment, but I’m definitely not there yet! LOL