General
Is there some slick way to do this?
Started by mh175 on .
Sign in or create an account to join the conversation.
With one line of code? I'm tired of typing all this. I just want the value a to increment by one in my multipad object. Can't I specify a range for Pads.x and then tell a to find the position of the button press?
if (Pads.x[0])a=1;
if (Pads.x[1])a=2;
if (Pads.x[2])a=3;
if (Pads.x[3])a=4;
if (Pads.x[4])a=5;
if (Pads.x[5])a=6;
if (Pads.x[6])a=7;
if (Pads.x[7])a=8;
if (Pads.x[8])a=9;
if (Pads.x[0])a=1;
if (Pads.x[1])a=2;
if (Pads.x[2])a=3;
if (Pads.x[3])a=4;
if (Pads.x[4])a=5;
if (Pads.x[5])a=6;
if (Pads.x[6])a=7;
if (Pads.x[7])a=8;
if (Pads.x[8])a=9;
Hi
One way would be -
firstof(Pads.x)!=sizeof(Pads.x)?firstof(Pads.x)+1:0 //returns Pad.x +1 or ) if nothing pressed.
One way would be -
firstof(Pads.x)!=sizeof(Pads.x)?firstof(Pads.x)+1:0 //returns Pad.x +1 or ) if nothing pressed.
Thank you!