tags:

views:

62

answers:

2

I was wondering what conditions were used to check the connection at the other end of the line.

Case 1: Computer dials a number, and a human picks up the phone, computer disconnects and moves on to the next phone number.

Case 2: Computer dials a number, and a modem answers, computer disconnects and records the number as being a computer.

What sort of if/else statement would be used for this?

A: 
while(currentNumber < numbersToDial)
{
    DialNumber(number)
    if(ModemToneDetected)
    {
        // it's a computer
        AddNumberToList(number);
    }
    else
    {
      // it's not a computer
    }
}
ctacke
+1  A: 

You could of course do it recursively, using something similar to this...

void TryNumber(int _number)
{
  if(_number > m_maxNumber) return; // exit out from the method if we've gone over our max number to dial

  DialNumber(_number);

  if(m_modemToneDetected) m_modemList.Add(number); // add number to a list if it's a modem

  TryNumber(_number + 1); // and back in to the method again!
}

m_modemToneDetected being a boolean that would be adjusted during the call to DialNumber()

Lee