I've run into this situation a long time ago, and for the life of me I can't remember the answer.
Within a function, what's the maximum number of "else if" statements you can use before they're no longer read?
For example:
Code:
else if (SKILL >= 10 && SKILL <= 49)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_1);
return;
}
else if (SKILL >= 50 && SKILL <= 99)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_2);
return;
}
else if (SKILL >= 100 && SKILL <= 149)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_3);
return;
}
else if (SKILL >= 150 && SKILL <= 199)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_4);
return;
}
else if (SKILL >= 200 && SKILL <= 249)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_5);
return;
}
else if (SKILL >= 250 && SKILL <= 299)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_6);
return;
}
else if (SKILL >= 300 && SKILL <= 349)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_7);
return;
}
else if (SKILL >= 350 && SKILL <= 399)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_8);
return;
}
else if (SKILL >= 400 && SKILL <= 449)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_9);
return;
}
else if (SKILL >= 450 && SKILL <= 499)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_10);
return;
}
else if (SKILL >= 500 && SKILL <= 599)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_11);
return;
}
else if (SKILL >= 600 && SKILL <= 699)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_12);
return;
}
else if (SKILL >= 700 && SKILL <= 799)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_13);
return;
}
else if (SKILL >= 800 && SKILL <= 899)
{
text_from_sql(ch, SQL_TITLE_APPRAISAL_14);
return;
}
// etc, etc...
Let's just say I kept going with 50 more "else if"s. As I stated, I ran into this problem before where I actually had "too many" and the function pooped out. I recall that I fixed the problem with the "switch" statement. However, I'm not able to use "switch" in this case.
Anyway...... I know there is a maximum number of "else if"s you can use, but I don't remember. Does anyone know/recall?
Thanks in advance.