Page 1 of 1

Is there some slick way to do this?

Posted: 25 Feb 2013 00:22
by mh175
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;

Re: Is there some slick way to do this?

Posted: 25 Feb 2013 01:52
by Macciza
Hi
One way would be -
firstof(Pads.x)!=sizeof(Pads.x)?firstof(Pads.x)+1:0 //returns Pad.x +1 or ) if nothing pressed.

Re: Is there some slick way to do this?

Posted: 25 Feb 2013 03:24
by mh175
Thank you!