Loopy Problem - Timed Action

Alphabeta, thanks again, I'll try rewriting the code to that structure and let you know what happens. i think the idea of containing the code in a while loop sounds good.

The only thing is the logic i was working to had a couple more stages
main loop:

  1. handset down - no tone
  2. handset picked up without ringing - dial tone

ring loop to happen every 30 mins:
3. check if handset is picked up or not. if it is wait 30 seconds then check again. if it isn't start ringing.
4 when handset is picked up play message.
5 when handset is put down stop playing message and return to main loop

PaulS. the results i have got from the code so far:
one statement is run each time the loop is called. it then waits the 60 second interval for the loop to be called again before moving on to the next statement. for example the last time i ran the code;
handset is up. the first if statement returns true and there is a delay it should be 30 seconds then check to see whether the handset is up or down.
instead after 30 seconds we return to the main loop. then if the handset is down after another 30 seconds the if statement turning on the ringing come back true.

at this point if the handset is picked up it should play the message. if the handset stays picked up, after a minute the next statement comes back true. the message plays. if the handset is put down at any point it is another minute before the next statement comes back true.

whilst each if statement has a minute wait between each time the ring loop is called it does not allow any functions of the main loop to happen during this time, giving the appearance of it being stuck whilst waiting for the recall.

here is the serial window log of the code being run

loop softswitch - picked up no ring 1
1 hookval HIGH - START VOID RING LOOP 1
1 softswitch - phone is picked up wait for 30 secs 1
loop softswitch - put down no ring 0
2 hookval LOW - START VOID RING LOOP 0
2.1 softswitch status ringing begin 0
3 hookval PHONE PICKED UP PLAYING MESSAGE 1
3 softswitch 4
4 hookval PHONE PUT DOWN STOP MESSAGE PLAYING 0
4 softswitch 0
END OF VOID RING LOOP 
2 hookval LOW - START VOID RING LOOP 0
2.1 softswitch status ringing begin 0

Looks like i've managed to write some really bad code... Thanks for your patience... I'll try and revise it and post something better.