mIRC Home    About    Download    Register    News    Help

Print Thread
Shortening a long if statement #204977 08/10/08 02:49 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello,

I was wondering wether or not there was a way to short this huge if statement

Code:
  ;elseif ($5 == LANGUAGE) { var %l = $remove($6,:) | if (%l == en) { %l = English } | if (%l == NL) %l = Dutch | if (%l == JA) %l = Japanese | if (%l == DE) %l = German | if (%l == AR) %l = Arabic | if (%l == FR) %l = French | if (%l == ES) %l = Spanish | echo %w $chr(149) Language: %l | halt }


Thanks a bunch.

Cheers,

Jay

Re: Shortening a long if statement [Re: Buggs2008] #204978 08/10/08 03:33 PM
Joined: Dec 2002
Posts: 2,011
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,011

Code:

elseif ($5 == LANGUAGE) {
  var %v1 = EN NL JA DE AR FR ES,%v2 = English Dutch Japanese German Arabic French Spanish
  echo %w $chr(149) Language: $iif($findtok(%v1,$remove($6,:),1,32),$gettok(%v2,$v1,32),Unknown)
  halt
}



Re: Shortening a long if statement [Re: Buggs2008] #204979 08/10/08 03:37 PM
Joined: Jun 2008
Posts: 48
T
Typos Offline
Ameglian cow
Offline
Ameglian cow
T
Joined: Jun 2008
Posts: 48
I was thinking something like:
Code:
elseif ($5 == LANGUAGE) { echo %w $chr(149) Language: $replace($remove($6,:),en,English,NL,Dutch,JA,Japanese,DE,German,AR,Arabic,FR,French,ES,Spanish) | halt }

Good luck.


I've gone to look for myself. If I should return before I get back, please keep me here.
Re: Shortening a long if statement [Re: Buggs2008] #204980 08/10/08 03:42 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Thanks very much for the great help =)

Cheers,

Jay

Re: Shortening a long if statement [Re: Typos] #205003 09/10/08 01:13 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You should be using $replacex.

JA -> Japanese -> JapanSpanishe

-genius_at_work