Need help adding code to sample code

Here is the original code
(it is from a DTMF example)

created 2-12-2013 by Igor Ramos


#include <Tone.h>

Tone freq1;
Tone freq2;

const int DTMF_freq1[] = { 1336, 1209, 1336, 1477, 1209, 1336, 1477, 1209, 1336, 1477 };
const int DTMF_freq2[] = {  941,  697,  697,  697,  770,  770,  770,  852,  852,  852 };

int dr = 12; //dr goes high when data ready
int d0 = 11;
int d1 = 10;
int d2 = 9;
int d3 = 8;
int a1 = 6;
int a2 = 7;

char data_ready=0, data[4] = {0,0,0,0};
char data_ready_status=0;
char dr_serviced=0;
char tx_in_progress=0;

void setup() {      

    Serial.println("Dossant DTMF Module: Loopback example");   
 // initialize the digital pin as an output.
   pinMode(d0, INPUT);    
   pinMode(d1, INPUT); 
   pinMode(d2, INPUT); 
   pinMode(d3, INPUT); 
   pinMode(dr, INPUT); 

// the loop routine runs over and over again forever:
void loop() {
static unsigned long int time, task, tx_time;
char tmp;

   time = millis();
   data_ready_status = digitalRead(dr);
   if (time - task > 1000) // send random char every 500ms
      task = time;
      if (tx_in_progress)
        Serial.println("Rx Timeout");  
       char randNumber = random(9);
       Serial.print("\n\rTransmitting DTMF: "); 

       playDTMF(randNumber, 500);
       tx_in_progress =1;

   if (data_ready_status) 
     if (!dr_serviced)
       //read data pins
       data[0] = digitalRead(d0);
       data[1] = digitalRead(d1);
       data[2] = digitalRead(d2);
       data[3] = digitalRead(d3);
       tmp = dtmf_digit(); //assemble dtmf digit;
       Serial.print("DTMF digit received: ");
       dr_serviced =1; //clear received flag
       tx_in_progress =0;    //clear  tx in progress flag

     dr_serviced =0;

// ----DTMF receive functions ----
char dtmf_digit ( void  )  //assemble the bits into a digit
 char dtmf_digit;

// dtmf digit is decoded per Page 5 Table 1 of chip datasheet

 dtmf_digit = 8* data[3] +  4* data[2] + 2* data[1] + data[0] ;
 if (dtmf_digit==10)
   dtmf_digit =0;
 return dtmf_digit;

// ----DTMF Send functions ----
void playDTMF(uint8_t number, long duration)
{[number], duration);[number], duration);

The code/function I want to add is

I want it to get 5 readings from the DTMF before it returns any data
So I want it to take those 5 readings as one reading (as a combined number)
Example if it got the following numbers “6,2,6,8,0” it would store it in a variable as “62680”
Then print the number

Another way of explaining

I send a DTMF tone “6” – it stores 5 to variable named “tone_bank”
I send a DTMF tone “2” it adds 2 to variable named “tone_bank” *now “62”
I send a DTMF tone “6” again-- it adds “6” to variable “tone_bank” (that value now “626”)
I send a DTMF tone “8” it adds “8” to variable named “tone_bank” (that value now “6268”)
I send a DTMF tone “0” it adds “0” to variable named “tone_bank” that value now “62680”)
since the count is now 5 it then “prints” the variable

Welcome to the Forum. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags which make the code looklike thiswhen posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

If you have already posted without using code tags, open your message and select “modify” from the pull down menu labelled, “More”, at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the “</>” icon at the upper left hand corner. Click on the “Save” button.

Thanks for the Welcome

And I fixed the post as you suggested

Thank you. You can accumulate digits in an array.

   if (time - task > 1000) // send random char every 500ms

Yeah, right. If you are going to have useless comments, you absolutely, positively MUST make them accurate and keep them accurate as the code changes.

I send a DTMF tone "6" -- it stores 5 to variable named "tone_bank"

SENDING random DTMF tones, as that code does, has NOTHING to do with RECEIVING DTMF tones, as that code also does.

You KNOW what you want to do. So, why don't you just do it?

I send a DTMF tone "2" it adds 2 to variable named "tone_bank" *now "62"

5 + 2 is NOT 62. Why would you store 5 in the variable when you get a 6?

Here's a clue, though:
6 * 10 + 2 does equal 62.