SysEx uses hexadecimal system for its messages, so I think you'd have to somehow translate the variable on the fly. Maybe custom module would be the best for this.
i encourage to use a custom module (i think for such things it is needed), you can take a look at my project where i did a lot of sysex conversion. GitHub - schoko11/KEKO-Kemper-Control: Control your Kemper by MIDI via Touchscreen
(maybe not that easy at first look, but you get a starting point) -> but be warned i am a beginner, don't expect too much.
@ GeneralMidi: I had tried several things including the get() function. I got neither of them to work, which was a clear sign of my inexperience with both OSC and Javascript (I'm not a coder).
Today however, after several hours of trying things out and studying examples I got it working.
It may not seem like much yet for me it's a little victory.
I created a fader and put these lines in the script field:
var nn = get("this"); // nn gets the fader position (0..127)
send("/sysex", "F0 43 11 62 02");
send("/sysex", nn);
send("/sysex", “F7")
@ abstrus: thanks for sharing your project with the community. Very informative. Writing a custom module myself without the required Javascript experience is a bit too daunting at the moment. Perhaps in the near future I'll learn a little more of Javascript. For now I'm already very pleased with what I can make OSC do.
Thanks for this addition! Working with decimal numbers is even better.
Actually I started with a concatenated version, which didn't work at first because I made a silly syntax mistake.
Is there anything which can't be done when concatenated, while possible when split up in multiple calls? For instance:
var faderValue = get("this");
var offset = 16;
send("/sysex", "F0 66 10 32");
if (@{pitch} >= 60)
{
send("/sysex", faderValue);
} else {
send("/sysex", faderValue + offset)
}
send("/sysex", "F7")
I guess with slightly more advanced code almost anything can be done within the send statement. Maybe only less readable.