Limit Switch Runs two different Programs based on presses

Im making a light switch that is a motor hooked up to a hand. When the limit swtich is pressed once the motor turns the hand one way and when the limit switch is pressed twice the motor turns the hand the other way. Im programming in robotC I am very new to the programming game and would greatly appreciate some help.

Just use a while loop and two if statements. Also Iā€™d recommend you look up a C programming tutorial first.