how to use setexpression with radiobuttons

Discuss problems and solutions.
Post Reply
jbgeluid
Regular
Posts: 60
Joined: 16 Jan 2012 14:03

how to use setexpression with radiobuttons

Post by jbgeluid »

hello,

I am trying to set a radiobutton to a certain state with another button, but it does not work.
what i tried:

1. to use a normal "button" to change the state of another button called CustomButton2, this script works;
"button" sets ' CustomButton2.x to "on" or to "1'..
script used in the "button":
setexpression(CustomButton2,' x', 1);

2. to convert this script so it will be usable for radioswitches, normaly you adress a radioswitch like this: 'x[0]' for the first button, 'x[1]' for the second button and so on.
so I expect the script for a radiobutton called "Switches" with 3 buttons ( 'x[0]', 'x[1]', and 'x[2]') to be;

setexpression(Switches, 'x[1]', 1);

to set the radioswitch to the "second button" so to speak.
this does not work..
I also tried:

decl ind=firstof(Switches.x);
setexpression(Switches, 'x[1]', 1);

and tried if adding the state of all the other buttons in the radiobutton would make a difference:
setexpression(Switches, 'x[0]', 0);
setexpression(Switches, 'x[1]', 1);
setexpression(Switches, 'x[2]', 0);

none of this works.
Odley enough the script:

setexpression(Switches, 'x', 1);

works, this sets ALL the radioswitches buttons to on (or off when you use '0' instead of '1').

Does anybody know what I am doing wrong here?

thanks,
Jurgen
Cubase 11, Windows 10/
Intel I7 4930K @3.4Ghz/
multiple RME hammerfall cards
Controllers: Ipad2/16gb, Lemur, BCR2000
http://www.jbgeluid.nl
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: how to use setexpression with radiobuttons

Post by Softcore »

Actually I have a question...

why not use

Code: Select all

Custombutton.x=0;
and go with the setexpression approach?

Consequently why not

Code: Select all

Switches.x[0]=1;
...Doesnt it work?
jbgeluid
Regular
Posts: 60
Joined: 16 Jan 2012 14:03

Re: how to use setexpression with radiobuttons

Post by jbgeluid »

Yep, thanks..

I guess I was overcomplicating things, but I actualy found this previous way of scripting in the manual...

Your solution:

Code: Select all

Switches.x[0]=0;
Switches.x[1]=1;
Switches.x[2]=0;
works, this sets the switch to the middle position...

Thanks again, Jurgen
Cubase 11, Windows 10/
Intel I7 4930K @3.4Ghz/
multiple RME hammerfall cards
Controllers: Ipad2/16gb, Lemur, BCR2000
http://www.jbgeluid.nl
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: how to use setexpression with radiobuttons

Post by Softcore »

To this day I still havent found a use for 'setexpression' - I believe though it is to be used when the expression you want to set an object may be changed dynamically by scripting in the project....my stuff are up to now fairly simple so just setting the expressions like above works for me....I'd love to see an example however or a showcase where the 'setexpression' way is to be used and accomplishes something that cant be accomplished in other ways....
Post Reply