mIRC Home    About    Download    Register    News    Help

Print Thread
Not a Bug per se #70226 04/02/04 12:22 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline OP
Hoopy frood
OP Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
As title says, not really a bug, but an anomaly.

//if !$2 { echo -a $ifmatch }
$true
//if !$1 { echo -a $ifmatch }
$true
//tokenize 32 a | if !$2 { echo -a $ifmatch }
$true
//tokenize 32 | if !$1 { echo -a $ifmatch }
$true

//tokenize 32 | if !$0 { echo -s $ifmatch }
1
//tokenize 32 0 | if !$1 { echo -a $ifmatch }
1

Why are these returning 1 and not $true? smile

Re: Not a Bug per se #70227 04/02/04 01:26 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This is probably happening because !<something> is internally translated to the 'opposite' value. The opposite of 0 is 1. So !$1 and !$0 are considered 1, if $1 and $0 are 0. The opposite of $false is also $true, so !$false = $true. $true is also the opposite of $null, which not as obvious at first, but I can't see any better candidate for this.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Not a Bug per se #70228 04/02/04 04:20 AM
Joined: Feb 2003
Posts: 810
C
cold Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Is the opposite of N (N being >1) also 0? I can't see how this works when !$0 would be 0 if $0 was 2, 3 etc..


* cold edits his posts 24/7
Re: Not a Bug per se #70229 04/02/04 06:45 AM
Joined: Feb 2003
Posts: 2,680
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,680
This is so math operators don't break, I'm guessing. You can't > < >= <= $true against other numbers. Though this would be kinda sloppy to code, I suppose ( 1 > !2 ).

The only bug is that ( !0 == $true ) and not ( !0 > 0 ).

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: Not a Bug per se #70230 04/02/04 07:16 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline OP
Hoopy frood
OP Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
I did say I didn't consider it a bug.. (twice) smile
IMHO it should return $true if only for consistency.

Re: Not a Bug per se #70231 04/02/04 02:25 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
There is no way to tell what !$0 returns when $0 > 0. That's because $ifmatch is filled only by the last matching statement. You'd need something like $elsematch to test it.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Not a Bug per se #70232 04/02/04 02:32 PM
Joined: Feb 2003
Posts: 810
C
cold Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
I know that, I'm only guessing. By this logic, it shouldn't return $null nor $false in that case, for example..


* cold edits his posts 24/7
Re: Not a Bug per se #70233 04/02/04 06:59 PM
Joined: Feb 2003
Posts: 2,680
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,680
I know you said it wasn't a bug, per se.
*I* am. :tongue: heh.

Actually, I wish to change my last statement.
The only bug is that ( !0 == $true ) and not ( !0 > 0 ).

//if ( !0 ) echo -a $ifmatch == !0
//var %n = 0 | if ( !%n ) echo -a $ifmatch == 1

I would say both of these are desired results, and should simply be anticipated when scripting. Any non-zero number is as good as $true... perhaps Khaled should just make IF ( 1 == $true ) && ( 0 == $false ) succeed.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!