if in if

 

Hi!

I need someone with a bigger and smarter brain.

How can i do something like this:

Add conditions in an "if" only if another condition is true.

//------------------------------------------------------------------------------

if (condition1 && condition2 &&

                if (condition3==true) {condition4 && condition5} &&

                if (condition6==true) {condition7 && condition8)

  )

//------------------------------------------------------------------------------

Hope someone knows this or i'll have to write hundreds line of code.

 
Alexandru Ionut Comanoiu:

Hi!

I need someone with a bigger and smarter brain.

How can i do something like this:

Add conditions in an "if" only if another condition is true.

//------------------------------------------------------------------------------

if (condition1 && condition2 &&

                if (condition3==true) {condition4 && condition5} &&

                if (condition6==true) {condition7 && condition8)

  )

//------------------------------------------------------------------------------

Hope someone knows this or i'll have to write hundreds line of code.

if (condition1 && condition2)
{
    if (condition3==true)
    {
        if (condition4 && condition5)
        {
            if (condition6==true)
            {
                if (condition7 && condition8)
                {
                    .............................................................;
                    .............................;
                    ...............;
                }
            }
        }
    }
}

 
Mohammad Soubra:

Thanks for the reply, but i think i was'nt too clear. The first "if" should do something if the conditions are ok. But, if the other conditions are true the result should be different. In your example all the conditions have to be met.

To be more specific, the first two conditions in the first "if" are mandatory and the other ones are aplied filters. I don't know wich filter is aplied so i need to check the filters and add conditions to the first "if", only if the filters are active.

 
Alexandru Ionut Comanoiu:

Thanks for the reply, but i think i was'nt too clear. The first "if" should do something if the conditions are ok. But, if the other conditions are true the result should be different. In your example all the conditions have to be met.

To be more specific, the first two conditions in the first "if" are mandatory and the other ones are aplied filters. I don't know wich filter is aplied so i need to check the filters and add conditions to the first "if", only if the filters are active.

clarify please

 

I do not know what you want but maybe else will help you.

else
 
can you post the real code????
 

you can move if condition every where 

just like true false

if 1 && 2 met result else false result

other ways

if 1 && 2 not met = answer if answer is not met return 

 
Further more, please show limited code
 

I've done it!

(condition3 and condition6 are extern bool vars)

//--------------------------------------------------------

bool condition4 =true;

bool condition5 =true;

bool condition7 =true;

if (condition3==true)  { condition4 = blah blah.... ;

                                     condition5 = whathev......;}

if (condition6==true)     condition7 = fsdasfwerefdsf;

//--------------------------------------------------------------------------------------

if (condition1 && condition2      && condition4 && condition5  && condition7)

{

do something.....

}

//--------------------------------------------------------------------------------------

if... let's say some filters (condition3 and condition6) are false 4,5,7 are true so they does'nt alter the result. If the filters are true, 4,5,7 are taken in consideration in the if.

Anyway, thanks everyone!

 
you are welcome
Reason: