What is the easiest way to perform the following.

I have a routine which looks for a button push, then depending how many time the button is pushed it jumps to a routine. So for 1 button push, Routine 1, 2 Button pushes Routine 2 etc etc.

Then within each of the Routines is a confirmation LED which flashes to show how many times you pushed the button. 2 flashes = button pushed twice.

I then want a Confirmation GOSUB so that if the button is pushed say 3 times and the LED flashes 3 times, it gives you the opportunity to confirm your selection by pushing the button again.

So i would like a GOSUB which gives a 3 second window where if the button is pushed again after the flashes but at anytime during this 3 second window, the selection is confirmed and the GOSUB RETURNS, if no button is pushed within the 3 seconds window, the program starts over.

Can anyone assist with this. I'm a little stuck on how to use the timing function.

Many thanks.