FOR in WHILE loop

So I want to make a program that goes through its motions only WHILE a button is pushed. The program’s motions are within a FOR loop.
However when putting a FOR in a WHILE, it starts only when the button is pushed but then continues irregardless of button state.
Common sense tells me I need a feedback from within the FOR loop to trigger a button check in the WHILE but I’m not sure how…

Here’s the relevant section of the code:

void loop(){
  while(digitalRead(10) == HIGH){
    //sing the tunes
    int size = sizeof(melody) / sizeof(int);
    for (int thisNote = 0; thisNote < size; thisNote++) {

      // to calculate the note duration, take one second
      // divided by the note type.
      //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
      int noteDuration = 1000 / tempo[thisNote];
 
      buzz(melodyPin, melody[thisNote], noteDuration);
 
      // to distinguish the notes, set a minimum time between them.
      // the note's duration + 30% seems to work well:
      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes);
 
      // stop the tone playing:
      buzz(melodyPin, 0, noteDuration);
      }
  }
}

Maybe you could read the button in the for and break out if it’s gone low?

Again with the great minds, Jim. I type too slowly.

void loop()
{
  boolean state = digitalRead(10); 
  while(state == HIGH)
    {
      //sing the tunes
      int size = sizeof(melody) / sizeof(int);
      for (int thisNote = 0; thisNote < size; thisNote++)
        {
            state = digitalRead(10);
            if(state == LOW)
              {
                 break;
               }

I'll give that a go! Thanks again.

The Break worked. I knew it had to exist, didn't know what it was. Perfect, thanks!