Start/Stop program by pushing a button

Kind of like a toggle?

bool runCODE;

void loop(){
// read button1

    if(button1 == HIGH && runCODE == false){
      runCODE = true;
    }
    if(button1 == HIGH && runCODE == true){
      runCODE = false;
    }
    if(runCODE == true){dothisFunction();}
}

void dothisFunction(){
  //do stuff here
}