If with lots of else if

How Can I create if statement with lots of else if (i need it to check ir signal)
send me code please. THANKS!

Really?

if (....) {
....
//repeat as many times as required
} else if (.....) {
....
} else (....) {
//final catch all else
}

(deleted)

pcbbc:
Really?

if (....) {

....
//repeat as many times as required
} else if (.....) {
....
} else (....) {
//final catch all else
}

ok,so i'm making if then some else ifs and then last normal else?

imalfectyt:
ok,so i'm making if then some else ifs and then last normal else?

It's a good idea to try the code that has been suggested before asking your next question.

If your program does not work as expected then post the program and tell us in detail what it actually does and what you want it to do that is different. Then we can focus on the parts you need help with rather than wasting time on things that you can do.

...R

ok,so i'm making if then some else ifs and then last normal else?

it's all just a normal if/else statement

They are just nested, so in the first else, you happen to have a new if/else statement etc.
the last else is the else of the last if.
because they are nested you only reach the last else if everything else was evaluated to false

that's the typical if/else statement

if ([color=red]condition1[/color]) 
  [color=blue]statement1True[/color]
else 
  [color=purple]statement1False[/color]

what you do is that

[color=purple]statement1False[/color]

is actually again an if/else statement

if ([color=red]condition2[/color])
  [color=blue]statement2True[/color]
else
  [color=purple]statement2False[/color]

so you get

if ([color=red]condition1[/color]) 
  [color=blue]statement1True[/color]
else 
  if ([color=red]condition2[/color])
    [color=blue]statement2True[/color]
  else
    [color=purple]statement2False[/color]

and then

[color=purple]statement2False[/color]

is actually again an if/else statement.. rince and repeat ad nauseam

Look at any of the thousands of IR decode sketches out there, first of all the library examples. They will all have some kind of solution for this...

Robin2:
It's a good idea to try the code that has been suggested before asking your next question.

If your program does not work as expected then post the program and tell us in detail what it actually does and what you want it to do that is different. Then we can focus on the parts you need help with rather than wasting time on things that you can do.

...R

sorry!

If your string of 'if/else' statements is comparing one integer variable against a list of integer constants, like this:

  if (integerVariableA == integerConstant1)
  {
    // matches integerConstant1
  }

  //repeat as many times as required
  else if (integerVariableA == integerConstant2)
  {
    // matches integerConstant2
  }
  else if (integerVariableA == integerConstant3)
  {
    // matches integerConstant3
  }
  else if (integerVariableA == integerConstant4)
  {
    // matches integerConstant4
  }
  .
  .
  .
  else if (integerVariableA == integerConstantN)
  {
    // matches integerConstantN
  }
  else
  {
    // final catch all else
  }

You should use a 'switch/case' statement like this:

  switch (integerVariableA)
  {
    case integerConstant1:
      // matches integerConstant1
      break;

    case integerConstant2:
      // matches integerConstant2
      break;

    case integerConstant3:
      // matches integerConstant3
      break;

    case integerConstant4:
      // matches integerConstant4
      break;
      .
      .
      .
    case integerConstantN:
      // matches integerConstantN
      break;

    default:
      // final catch all else
  }