MIDI toggle global/local rackspace view

Hello there! I am having trouble figuring out how to toggle the global rackspace view using a MIDI CC (apart from clicking or using ctrl-g). I have tried making a script using the function ShowGlobalRackspace (show : boolean) but keep getting error messages. Any support would be greatly appreciated!

1 Like

Are we supposed to guess the error message?

1 Like

Let me see what the errors could be…
image

4 Likes

:roll_eyes:
I had deleted my (pitiful) attempt so didn’t have the error messages on hand, was hoping there would be a simple solution. Here is the scriptlet:

var
GlobalToggle : Discrete Parameter “Global”, “Local” = “Global”

On ParameterValueChanged matching GlobalToggle
ShowGlobalRackspace (show : boolean)
End

and here is the error:

Scriptlet (Scriptlet) - - Syntax Error in “Main”: Line 5, Col 5: Unexpected or unrecognized token: ‘ShowGlobalRackspace’
Mismatched input ‘ShowGlobalRackspace’ expecting End

Test with something like that:

ShowGlobalRackspace (GlobalToggle == “Global”)

I realized that I think I need to “declare” (not sure if that’s the right word) the showglobalrackspace function at the beginning, now I have been able to compile it without errors at least. But using GlobalToggle == “Global” the script is not doing anything when the parameter is changed:

var
GlobalToggle : Discrete Parameter “Global”, “Local” = “Global”
function ShowGlobalRackspace (show : boolean)
End

On ParameterValueChanged matching GlobalToggle
ShowGlobalRackspace (GlobalToggle == “Global”)
End

I doubt it whether ShowGlobalRackspace is available in scriptlets, as they are in fact plugins, so like normal plugins they have little consciousness of there environments.

Furthermore beware of the double quotes when copying: Webpages tend to display fancy ones (the first upside down). These do not compile

"<- these quotes are the right ones ->"
2 Likes

@Frank1119 is absolutely right - in a scriptlet it’s not allowed use the ShowGlobalRackspace() function, AND you’d have to use the correct quotation marks!

So you’d have to use a rackspace script to achieve this goal… but you can use the global rackspace itself, so the script and the widget would be needed only once in one sngle place (global rackspace)!

Place a button widget on the global rackspace panel and give it a handle (for my script i used “btn_toggle”):
2022-10-09 01_14_18-Window

Then open the global rackspace script editor and use this code (don’t forget to compile):

var
btn_toggle : widget

On WidgetValueChanged (bval : double) from btn_toggle
    If bval >0.6 then
        ShowGlobalRackspace(true)
    Else
        ShowGlobalRackspace(false)
    end
End

If you learn a MIDI controller to the button, you will be able to switch the global rackspace on and off from any place.

3 Likes

Thank you so much for this extremely generous reply, I really appreciate it! I will give it a try as soon as I get back to my PC.

Oh, indeed, this doesn’t help. :grimacing:

Then perhaps replacing this:

by this:

ShowGlobalRackspace( bval > 0.6 ) :nerd_face:

Maybe some hysteresis?

On WidgetValueChanged (bval : double) from btn_toggle
    If bval > 0.6 then
        ShowGlobalRackspace(true)
    end
    If bval < 0.4 then
        ShowGlobalRackspace(false)
    end
End

But the need for this depends on the physical controller: for a switch type you don’t need it, for a slider you might when you slide rather slow.

2 Likes

I guess I’ll never get used to using this short form… but of course this will work.
Besides that it definitely results in a shorter source code, has this any impact on computing speed or such?

@Frank1119 not a bad idea… if using a slider, my code would be a bit “lopsided”. :upside_down_face:

1 Like

If in a loop, probably, but not here on a single button press.

1 Like

There is also a function to get the previous widget value (something like GetWidgetPreviousValue(w : Widget) ).

Put an Else between those two If statements. No point in testing bval twice.

1 Like

Technically yes….no jump instructions are necessary.

1 Like

Hello! I am just getting back to this now, and the script has compiled successfully and is working somewhat, but it is not behaving as expected. If I am in the panel view, the script toggles the global rackspace panel popping up on top of the local rackspace panel. Otherwise, the script does not toggle the global rackspace view in the same way that the button/hotkey does. And if I press it too rapidly it crashes GP. I think I will just stick to those and give up the experiment, seems more of a hassle than it’s worth.

Yes, that function called ShowGlobalRackspace is actually to show/hide the panel, not to switch to the actual global rackspace.

I’m not aware of a script function to do what you want.

Do you have a crash report? What computer and OS are you running?