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

Because you are using string names rather than actual local widget declarations. Strings can have anything at all in them and so a check cannot be performed until the code is actually running and therefore there is no guarantee that a widget actually exists with that string name. So you have to test it and you can’t use function such as that SetExternalWidgetLabel unless the Bind was successful.

OK, I got it and for this direction it’s basically the same principle.

Widget callback
Use your long callback that you provided earlier and add the
SetExternalWidgetLabel(ew, "1: Clean" + stepperValues[index]) and so on to the conditions.

With this code the external widget label will be changed whenever you change the “RevDelStepper”. But the global rackspace doesn’t know yet that and where it should search for the external widget (that’s what dhj wrote).
That’s why we need the declaration (guess you already have that) and the binding of the external widget.
The binding works differently in the global rackspace since there exists no “On Activate” callback. I suggest you let that happen every time you change the local rackspaces. So we need this in the global script:

Binding of the external widget

On Rackspace(oldRackspaceIndex : integer, newRackspaceIndex : integer)
    If BindExternalWidget(ew, "widget handle", GetRackspaceNameAtIndex(newRackspaceIndex)) then
    End
End

You still need to fill in the handle of the local widget but note that it automatically uses the current rackspace name for the check whether this widget exists.

Thanks for those instructions. Just to establish that its working, I did a very simple test as per my understanding of your instructions. I just put a label widget in the local and added the handle “local”.

Then I added a widget to the global rs “global” and did this very simple script you sent. I am getting this error. What did I misunderstand?

Needs another End.
Once you add a conditional IF , then you need to bookend it with an End. The callback itself needs to be bookended with an End as well.

On {callback}
      If {conditions} then
           {statements}
      End
End

Right! I just copied and pasted as is, but you’re right. It did compile successfully, but still not working.

How looks your code now?

Exactly the same as before, except I added the extra “End” so it compiles. But the word “hello” is not sent or does not appear in the local rs label.

Please paste your code

And please describe what should be done by scripting?

@pianopaul asking me to re-paste my code forced me to reopen the testing gig file and it IS working now! I wasn’t working initially, but after restarting the gig file it is. Wonder how many hours I had wasted on things thinking its not working that might have been just fine. So why is this? Is there something I can do to test properly without restarting?

try this

hello.gig (61.0 KB)

this is because on rackspace is called when you switch a rackspace or when you load the gig file.

maybe you only have 1 rackspace and therefore it was not working.

I built the gig with 2 rackspaces and switched the rackspace and it was working.

There’s no need to restart. Re-compiling is all that’s required.

Sometimes you just have to accept that user-errors occur, shrug your shoulders and move on. :slight_smile:
It’s working now.

I see! That makes sense! Lesson learned! LOL

I did recompile of course. Multiple times! What about what Paul was saying about needing to switch rackspaces? In my initial testing gig file I only had one rackspace and after re-doing the whole thing, it didn’t work with 1 rackspace but did with 2 (without restarting and after recompiling). So at least in this particular case, the additional RS was needed to test properly.

Try with the following to check if it bound your local widget :

On Rackspace(oldRackspaceIndex : integer, newRackspaceIndex : integer)   If BindExternalWidget(ew, “widget handle”, GetRackspaceNameAtIndex(newRackspaceIndex))

Then

Print(“Bound “+GetRackspaceNameAtIndex(newRackspaceIndex))

End

End

Sorry, that’s right. I forgot that. I edited it above no one else will get an error.

That’s correct and means that the check whether the external widget exists only happens when you switch to a certain rackspace (that’s what the callback waits for).
So to see whether it works you must have activated another rackspace before you can switch to that specific one. When you reloaded your gig that happened automatically. When you only recompiled - obviously - not. :+1:

No, what was needed was having a rackspace to switch from and to. As you found, the On Rackspace callback won’t activate until you actually switch to that rackspace.

You should take some time with simpler scripting tasks (and the scripting manual in general) to get more familiarized with how things work.

So this has been extremely useful! @edm11 (OSC) and @Florian (BindExternalWidget) offered 2 very different solutions. I am happy to have learned both! Its always good to have multiple tools in your toolbox! :wink: Thanks everyone for helping!

Yes of course, but in order to do that I had to add another rackspace so I can switch TO the one I needed it. Stupid oversight for sure, but I only had 1 RS when testing. User error for sure!