quote:
Originally posted by roflmao456
quote:
Originally posted by CookieRevised
code:
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!b1"){
if(Message.substr(0,3)!="!b2"){
if(Message.substr(0,3)!="!b3"){
if(Message.substr(0,3)!="!c1"){
if(Message.substr(0,3)!="!c2"){
if(Message.substr(0,3)!="!c3"){
//dosomething
}}}}}}}}}
that is saying "if the message at 0,3 doesn't equal *this*, do this." ... should it be "if the message at 0,3 equals *this*, do this" ?
No
it should be if the message at 0,3 doesn't equal *this* AND doesn't equal *this* AND doesn't equal *this AND doesn't equal *this AND doesn't equal *this AND doesn't equal *this AND doesn't equal *this AND doesn't equal *this AND doesn't equal *this AND doesn't equal *this*, then do something.
quote:
Originally posted by CookieRevised
- Chage stuff like
code:
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!b1"){
if(Message.substr(0,3)!="!b2"){
if(Message.substr(0,3)!="!b3"){
if(Message.substr(0,3)!="!c1"){
if(Message.substr(0,3)!="!c2"){
if(Message.substr(0,3)!="!c3"){
//dosomething
}}}}}}}}}
to at least 1 check using an AND operator.
Or better yet, use a single regular expression.
So start by properly indenting your entire code (isn't the first time I strongly suggest you do this) and see what you exactly made with all those IF THEN's. A massive bunch of nested IF THEN....
This entire forest of IF THENs can be made into 1 simple check using alogical AND operator (aka: use &&).
...or learn regular expressions and put that entire bunch into one short check. PS: nope I'm not going to give you the regular expression as I want you to convert that whole bunch into 1 proper IF THEN check first