Is my condition of while wrong?

Thanks for reading my question. What happens is that I have a vibrating table with a keypad, so for button 1 when pressing so that the table moves so many steps, because I used motors step by step I used the for cycle but it does not help me much because I have to wait until that the cycle ends to change the button, what I want is that when you press the button 1 it moves in x, when you press the button 2 it moves in and, when you press the button 3 it moves in "x" and "and" finally button 4 would be to completely turn off the table. Would I have to use the while cycle for each button? that is, when in the conditional switch press button 1, it will take me to case 1 then the while cycle enters while I do not know how to assign variable t, that as long as t equals 10 it will keep putting the value of t = 10 from the beginning then when press button 2 this new cycle will be activated when t = 6 to assume but I do not know if it would be so, can you tell me if it is? NOTE: I already try to do it this way but, when I press button 1 it works fine but when I press button 2 it does not change its address it stays in the address indicated on button 1. MANY THANKS

The problem is in the code you didn't post.

Hahahahaha sorry it's the first time I enter a forum