         #endif
       }   
       else {
+        numindex = 0;//empty 
         #ifdef DEBUG
         putstring_nl("hang high");
         #endif

FatReader f;      // This holds the information for the file we're play
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

const int hangPin = 6; //pin for reciever switch. closed (HIGH) when hung up, open (LOW) when off the hook
const int dialPin = 7; //pin for dialing switch. close (HIGH) when  dialing, open (LOW) when not dialing
const int countPin = 8; //pin for counting switch.  closed (HIGH) for don't count, open (LOW) for each count
const int ledPin = 13; //LED pin

int dialCount = 0;
#define DIAL_ARRAY_LEN 50
int dialArray[DIAL_ARRAY_LEN];
int dialIndex = 0;


  wave.play();
}


#define NUMMAX 10
short nums[NUMMAX];
short numindex = 0;//points to first empty space
char FileName[NUMMAX+5];

void addnum(char num) {
  if(numindex < NUMMAX) {
    nums[numindex++] = num;
  }
  #ifdef DEBUG
  else {
    Serial.println("numindex over max");
  }
  #endif//DEBUG
}

void removenum() {
  if(numindex > 0) {
    --numindex;
  }
  #ifdef DEBUG
  else {
    Serial.println("trying to remove from empty num list");
  }
  #endif//DEBUG
}

short fillnum() {
  short fnindex;
  {for(fnindex = 0; fnindex < numindex; ++fnindex) {
    Serial.println(nums[fnindex]);
    FileName[fnindex] = (char)(nums[fnindex] + '0');
  }}

  return fnindex;
}

void makeFileName() {
  short fnindex = fillnum();

  FileName[fnindex++] = '.';
  FileName[fnindex++] = 'w';
  FileName[fnindex++] = 'a';
  FileName[fnindex++] = 'v';
  FileName[fnindex++] = '\0';
}

void printFileName() {
  makeFileName();
  Serial.println(FileName);
}

void setup() {
  
