A Little Help Programming Please

I need a little help. This is a simple button(5) code just to open close a servo(0),
The only change i need is my main loop to be activated when i press the button for 5 secconds. Thank you

 goto main_loop    
  
 sub button
   5 get_position 500 less_than
   return
  
 sub wait_for_button_press
 wait_for_button_open_10ms
 wait_for_button_closed_10ms

   return

 sub wait_for_button_open_10ms
   get_ms # put the current time on the stack
   begin
     
     button
     if
       drop get_ms
     else
       get_ms over minus 10 greater_than
       if drop return endif
     endif
   repeat
  
 sub wait_for_button_closed_10ms
   get_ms
   begin
     button
     if
       get_ms over minus 10 greater_than
       if drop return endif
     else
       drop get_ms
     endif
   repeat
  
 main_loop:
 begin
 800   frame 
 8000  frame
  
 repeat

 sub frame
 wait_for_button_press
  0 servo
 return

From your description, it is not clear to me if you want your code to wait until the button is pushed for 5 seconds before going to the main loop, or if you want your main loop to require the button presses to be held down for 5 seconds. However, you can make a simple modification to the wait_for_button_open_10ms subroutine to make a new subroutine that requires a 5 second button press to return true. For example, you can change the 10 to 5000, which results in the subroutine that I named wait_for_button_open_5000ms below:

sub wait_for_button_open_5000ms
   get_ms # put the current time on the stack
   begin
     
     button
     if
       drop get_ms
     else
       get_ms over minus 5000 greater_than
       if drop return endif
     endif
   repeat

If you try incorporating this into your script and run into problems, can you post your new code, as well as a description of what is happening and what you want to happen?

Brandon