welcome to the arduino-Forum
read this short tutorial on how to post code as a code-section
additional here is a tuotrial how to write code for having different modes of operation
a description very similar to Delta_G's description just using the word "mode"
Initial mode Servo is at 0
mode 1: Servo starts moving towards 90. When it gets to 90 enter state 2
mode 2 : Servo starts moving back towards 3 degrees. If the touch sensor is triggered in this state then return to state 1. If you reach 3 degrees then enter state 3.
mode 3: Servo moves to 180 and does not leave this state.
in programming such modes of operation are called "states" and the code that realises such multiple modes of operation is called a state-machine