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.

11-09-2006

Dark_Phoenix

This may be a bit overkill, but couldn't you just use a look up table instead of using if/else or switch's?

11-09-2006

Dave_Sinkula

It's up to the implementation what the limit on nesting level is, but the standard does guarantee minimums.

That code will solve your problem neatly. It first creates a list to contain all the different values of SQL_TITLE_APPRAISAL_X which I guessed were std::string but you can change that easily. Then, it proceeds to check that SKILL is >= 10 and ensure that we do not access an index outside of the range the list can access. Dividing SKILL by 50 gives us the index in the list (49 / 50 will be rounded to 0, which is the first index, for example).

Have fun.

Edit: Fixed mistake in code as suggested by CornedBee.

11-10-2006

anon

Good that compiler finally told you there's something wrong with the way you are coding. Your case is a bit more complicated than above, but you should still look out for patterns and use arrays or some other containers. (Skill needs to be at least 10. From 10 to 500 it goes in steps of 50, then in steps of 100. Etc. It wouldn't hurt to plan the rules of your game so, that you wouldn't have to wrestle with irregularities and exceptions later.)