mIRC Home    About    Download    Register    News    Help

Print Thread
#250640 25/01/15 12:47 AM
Joined: Oct 2003
Posts: 214
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 214
Was the handling of this changed?

Because, if (!1) is true, while if (!$len(1)) is false.

As far as i can see, both are the same.

Greetings.


one step closer to world domination
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
The difference is that "!1" is a literal string. Like "!help" is a literal string. You can only prepend "!" before a variable (%var), identifier ($me) or an operator (isin). Try the following examples:

//if (!1) { echo -a true $v1 } | else { echo -a false $v1 }
//if (!help == !help) { echo -a true $v1 } | else { echo -a false $v1 }
//if (!$true) { echo -a true $v1 } | else { echo -a false $v1 }
//if (!$true == $false) { echo -a true $v1 } | else { echo -a false $v1 }



Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Raccoon #250642 25/01/15 12:54 AM
Joined: Oct 2003
Posts: 214
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 214
I did, but it never triggered like that before.

And if i negate a string, it shouldn't return true.

Because if (string) is true... so if (!string) can't be true too.

//echo $iif(1,1,0) $iif(!1,1,0)

Last edited by Sephiroth_; 25/01/15 12:57 AM.

one step closer to world domination
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I just edited my post with additional information.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Raccoon #250645 25/01/15 01:00 AM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Consider the following, how do you think it should behave?

if (!search* iswm $1-) { /xdccfind $2- }

if "!search*" turns into "$false" then it wouldn't be "!search" anymore.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Raccoon #250646 25/01/15 01:07 AM
Joined: Oct 2003
Posts: 214
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 214
Well yeah i see what you mean, haven't thought of that.

Anyway this is a bit different from what i was looking for, but i understand what you mean and how it is triggered there. Even if you would negotiate iswm with !iswm.

So $iif(!$(1),1,0) will solve this for me by now.

It was a long week. wink

Good night.


one step closer to world domination
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I just can't imagine why you would manually hardcode your IF expression with a negated number if you could just as easily type $false or 0 or get rid of the IF all together.

Use a variable that has some meaning, instead of the naked number 1.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Raccoon #250648 25/01/15 01:18 AM
Joined: Oct 2003
Posts: 214
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 214
It has nothing to do with that, i just came up with it during a mistake on a script and didn't saw the "string" possibility.

Just because of other languages where numbers alone are always triggered as numbers even with the leading exclamation mark.

So... notice it as a mistake.


one step closer to world domination

Link Copied to Clipboard