replace delay(xxxx) with button press??

I have a 7 segment led running through a 74hc595 counting 0-9 with a small pause in between each
next incremental digit.

I would like to change this by adding a button press to go to the next digit up
Yes I am trying to make a scoreboard...

can delay(xxxx) be replaced by by adding instead
the code snippet from the button tutorial

I think i am having trouble understanding how to pause the shift register 74hc595 and restart it.

I found this sketch on the net
but I am stuck trying to modify it...

int dataPin = 11;
int clockPin = 12;
int latchPin = 8;
 
int len = 10;
 
//holders for infromation you're going to pass to shifting function
byte dataRED;
byte dataArrayRED[10];
 
byte off = 0x00;
byte decimalpoint = 0x80;
 
 
 
void setup() {
 
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
 
  //Arduino doesn't seem to have a way to write binary straight into the code
  //so these values are in HEX.  Decimal would have been fine, too.
 
  dataArrayRED[0] = 0x3f; //00111111 - 0
  dataArrayRED[1] = 0x06; //00000110 - 1
  dataArrayRED[2] = 0x5B; //01011011 - 2
  dataArrayRED[3] = 0x4F; //01001111 - 3
  dataArrayRED[4] = 0x66; //01100110 - 4
  dataArrayRED[5] = 0x6D; //01101101 - 5
  dataArrayRED[6] = 0x7D; //01111101 - 6
  dataArrayRED[7] = 0x07; //00000111 - 7
  dataArrayRED[8] = 0x7F; //01111111 - 8
  dataArrayRED[9] = 0x67; //01100111 - 9
 
}
 
void loop() {
 
int count = 100;
int val = 10; //this is for how many digits
 
 
 
for( int i = 0; i<count; i++ )
{
  digitalWrite(latchPin, 0);
 
 
   int digit2 = i % val;
  int digit1 = ( i - digit2 ) / val;
 
    shiftOut(dataPin, clockPin, dataArrayRED[ digit2 ]);
    shiftOut(dataPin, clockPin, dataArrayRED[ digit1 ]);
 
  digitalWrite(latchPin, 1);
  delay(30);                             //code for button here#############################
  delay(10);
}
 
}
 
 
// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first,
  //on the rising edge of the clock,
  //clock idles low
 
  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);
 
  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);
 
  //for each bit in the byte myDataOut…
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights.
 
  for (i=7; i>=0; i--)  
  {
    digitalWrite(myClockPin, 0);
 
    //if the value passed to myDataOut and a bitmask result
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000
    // and proceeds to set pinState to 1.
    if( myDataOut & (1<<i) ) 
    {
	pinState= 1;
    }
    else 
    {
	pinState= 0;
    }
 
    //Sets the pin to HIGH or LOW depending on pinState
 
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }
 
  //stop shifting
  digitalWrite(myClockPin, 0);
}

Think about what you mean by "pause and restart the shift register".

Is it that you want to hold off in displaying the next digit, and then start back and display the first digit again?

For the first part, you can write a loop that just checks for the button and only gets out of the loop when the button is pressed.
Something like this:

while(!digitalRead(pin)); // Assuming you want to continue when the button is HIGH

For the second part, there's a handy command called "continue" that skips the rest of what's happening in the loop function and goes back to the beginning.
I'd do something like this:

if(restart) {
    continue;
}

Also, the comment in the code

//Arduino doesn't seem to have a way to write binary straight into the code
  //so these values are in HEX.  Decimal would have been fine, too.

is not true at all. Just type B before you put in the ones and zeros. Only works in arduino, not c++, though.

For the second part, there's a handy command called "continue" that skips the rest of what's happening in the loop function and goes back to the beginning.

No, it doesn't. The continue statement skips the rest of a loop construct (for, while, do/while) and performs the end-of-loop increment (if any) and continue-execution (if any) steps. It does NOT skip the rest of the loop function.

To do that, use return (and look like an idiot). Proper use of if statements will avoid the need to return in the middle of a function.