Jump to content

Is there an IF limit?


Zener25

Recommended Posts

I have written the following script as part of a dynamic forum signature.

 

// Play Style Script ----------------------------------------------------------
plytype="G.I. Soldier DEF";

plygistyp="G.I. Soldier";
plyairtyp="Airborne";
plymartyp="Marine";
plycomtyp="Commando";
plysprtyp="Sniper";
plysabtyp="Saboteur";
plyarityp="Armoured Infantry";
plyobstyp="Observer";
plyfobtyp="Forward Observer";
plycchtyp="Crew Chief";
plycmetyp="Crew Medic";
plycmntyp="Crewman";

if((spectype==speccqbtyp)&&(exptype==expexptyp)) {plytype=plysabtyp;}
if((spectype==specfamtyp)&&(exptype==expexptyp)) {plytype=plysabtyp;}
if((spectype==specsprtyp)&&(exptype==expexptyp)) {plytype=plysabtyp;}
if((spectype==speccqbtyp)&&(exptype==expmfctyp)) {plytype=plyfobtyp;}
if((spectype==specfamtyp)&&(exptype==expmfctyp)) {plytype=plyfobtyp;}
if((spectype==specarmtyp)&&(exptype==expfretyp)) {plytype=plycchtyp;}
if((spectype==specsprtyp)&&(exptype==expffatyp)) {plytype=plysprtyp;}
if((spectype==specsprtyp)&&(exptype==expfrptyp)) {plytype=plysprtyp;}
if((spectype==specsprtyp)&&(exptype==expfretyp)) {plytype=plysprtyp;}
if((spectype==specsprtyp)&&(exptype==expanttyp)) {plytype=plysprtyp;}
if((spectype==specsprtyp)&&(exptype==expaidtyp)) {plytype=plysprtyp;}
if((spectype==specsprtyp)&&(exptype==expmfctyp)) {plytype=plyobstyp;}
if((spectype==specairtyp)&&(exptype==expffatyp)) {plytype=plycmetyp;}
if((spectype==specarmtyp)&&(exptype==expffatyp)) {plytype=plycmetyp;}
if((spectype==specbottyp)&&(exptype==expffatyp)) {plytype=plycmetyp;}
if((spectype==specairtyp)&&(exptype==expfrptyp)) {plytype=plycmntyp;}
if((spectype==specarmtyp)&&(exptype==expfrptyp)) {plytype=plycmntyp;}
if((spectype==specbottyp)&&(exptype==expfrptyp)) {plytype=plycmntyp;}
else {plytype=plygistyp;}

plytype_color = "ffffff";

text(x: col7, y:line2_y, text: concat(plytype), size:12, align:"left", font:damaged, color:plytype_color);

 

You'll notice I have used an IF,ELSE format (with a lot of IFs!).

 

The problem I have is that the script functions perfectly when I use 7 IFs followed by an ELSE.

 

However, when I exceed this apparent 7 IF limit, the script reverts to giving the ELSE value ({plytype=plygistyp;})

 

 

- Is there a limit to the number of IF statements that can be used in an IF,ELSE format?  :confused:

 

- Can anyone offer any help/solutions to my problem, please?  :confused:

 

- Could this be done better using some form of array?  :shrug:

Link to comment
https://forums.phpfreaks.com/topic/207346-is-there-an-if-limit/
Share on other sites

There's no such limit, although your need for such constructs indicates something's wrong with your design. Also note that correct usage is

 

if() {} 
elseif () {} 
elseif() {} 
else {}

 

Is this PHP or JavaScript by the way?

 

Thank you Mchl!!  :-*

 

I have ammended the script (IF,ELSEIF,ELSE) accordingly and it is now working!  :D

 

I realise this is a schoolboy error  :-[ I'm just a beginner  :D

 

I did try this at an earlier stage of testing, but probably had something wrong somewhere else at that time and so reverted to IF,IF,IF... for some reason  :-[

 

This has held me up for about a week as no one else bothered to reply to my posts on other forums.  :confused:

 

Thank you again Mchl, and thanks PHPfreaks!  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.