mIRC Home    About    Download    Register    News    Help

Print Thread
#234983 18/11/11 06:07 PM
E
eawedat
eawedat
E
hey all,

How could I check if Identifiers are set?(not empty)

Code:
 if ($2 != "") && ($3 != "") && ($4 != "") {
    msg $chan $2
    msg $chan $3
    msg $chan $4
  }


what's wrong with the code above?

thanks.

#234985 18/11/11 07:00 PM
Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
mIRC scripting doesn't use quoted strings (with a few exceptions); to check if a value is empty compare it with $null, ie., $4 != $null.

That said, the way mIRC's tokenization works (the way it fills $1, $2, etc.) prevents empty tokens from being allocated. So if $4 != $null then $1, $2, and $3 cannot possibly be $null either - therefore there is no need to check those.

E
eawedat
eawedat
E
Got it,,
or I could use if ($4) { }
thanks a lot starbucks_mafia.

Last edited by eawedat; 18/11/11 09:32 PM.
#234992 18/11/11 09:46 PM
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Not really. if ($4) fails if $4 is 0 or $false too.

E
eawedat
eawedat
E
right , I missed that:)

#234995 18/11/11 11:48 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Of course, if you know your data won't include 0 or $false or if those will also be treated like $null in your script, then you can safely use that. smile

Joined: Sep 2005
Posts: 2,630
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
Or 00, 000, 0000, etc after a recent change :p

[/pedant]


Link Copied to Clipboard