Zener25 Posted July 10, 2010 Share Posted July 10, 2010 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? - Can anyone offer any help/solutions to my problem, please? - Could this be done better using some form of array? Link to comment https://forums.phpfreaks.com/topic/207346-is-there-an-if-limit/ Share on other sites More sharing options...
Mchl Posted July 10, 2010 Share Posted July 10, 2010 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? Link to comment https://forums.phpfreaks.com/topic/207346-is-there-an-if-limit/#findComment-1084037 Share on other sites More sharing options...
Zener25 Posted July 10, 2010 Author Share Posted July 10, 2010 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! I realise this is a schoolboy error I'm just a beginner 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. Thank you again Mchl, and thanks PHPfreaks! Link to comment https://forums.phpfreaks.com/topic/207346-is-there-an-if-limit/#findComment-1084039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.