mIRC Home    About    Download    Register    News    Help

Print Thread
#217555 16/01/10 01:37 AM
Joined: Jul 2006
Posts: 4,180
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
$chan($active).mode returns 1 when $active is a status window, I think it's a bug, but would like to know if someone has any information about that, or if i should make a bug report


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2008
Posts: 95
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
It seems like $chan(), with or without the "mode" or any other property, returns the number of channels you're on (just like $chan(0)) if no channel name or number but 0 or anything that doesn't start with # or a number (such as "status window") is specified.

Joined: Jul 2006
Posts: 4,180
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
Yeah, I just realized, it's still odd smile

Edit : it's not $chan(0)it is indeed.

Last edited by Wims; 16/01/10 01:56 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Not sure. It returns 0 in my status window when there are no active channels open.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
This is why, in my opinion, $active should only be used in instances where you have no other option.

Joined: Jul 2006
Posts: 4,180
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
$active should be used when you want to refer to the $active window... What is your point ?
My point was about $chan() returning a value for a window that in't a channel, but in fact (and in general in mIRC) it takes any invalid parameter as 0.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Sorry, my point is:

$active should only be used in instances where you have no other option.

Invalid parameter = $null
$null = 0

Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
$null = 0 ?!
dont think!


WorldDMT
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Realistically, for the situation in the topic, $null has the relative value of 0.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
But then - to my knowledge - no other identifier handles a "text"-parameter in this way.
While it's the missing chantype prefix ( $chan(#status window).mode is $null, like $chan(#).mode ), I'd find it apt to return $null for all "non-numeric" params that are no existing channel, regardless of a missing chantype char...

At the moment:
//echo -a $chantypes --- $chan(&bla).mode
NetA: #& ---
NetB: # --- N [same as $chan(0)]

That aside, $chan($null) is the same as $chan(), not $chan(0). It's a big difference whether an invalid parameter is treated like $null or 0.

Last edited by Horstl; 19/01/10 04:50 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
To my knowledge, using a non-numeric where the identifier is expecting a numeric, the non-numeric is treated as a value of 0.

That is consistent with what I stated, although I probably could've stated it better.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Originally Posted By: Horstl
But then - to my knowledge - no other identifier handles a "text"-parameter in this way.
There are quite a few, such as $gettok(a b c,blah,32), $line(windowname,blah), $findfile(.,*,blah,1), $sock(*,blah). In fact, excluding cases where an identifier has to discriminate between numbers and non-numbers (such as $nick()), I can't find a counterexample.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Sorry for the ambiguity, I was talking about the sort of identifiers that take either <N> or <text> and take a single parameter. Identifiers like $send $get $query $chat $notify $ignore $server $highlight $ignore $disk $timer etc.
I'm aware of the fact that in places where the syntax demands <N>, mIRC will treat <text> like 0 (= invalid parameter).
In all the given examples, "0" returns the total (of a definite set of items - like your set of channels) and "no match for <text> or <N>" returns $null (no matching item found). Wouldn't it be apt to have it return $null if there's "no match for the text <chan>" - even if you didn't use any of the chantype prefixes? Is there any advantage in necessitating the prefix, and treat <text> as invalid parameter without it? Maybe I just don't see it... smile

Edit: replied to the wrong nick whistle

Last edited by Horstl; 19/01/10 02:17 PM.
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I don't think there's any functional advantage either, it seems more like a semi-arbitrary implementation decision. It's a bit counterintuitive indeed, in the sense that for the same string (that does not correspond to an existing channel), $chan() gives different results, depending on chantypes. That said, I can't imagine why this would inconvenience anybody (especially since there is a proper way to check for a channel, namely ischan).

On a less serious note, this behaviour could be used as a shorter way of checking whether a string is a valid channel name, i.e. instead of doing
if ($left(string,1) isin $chantypes)
you'd do
if ($chan(string) !isnum)
and save a whole 11 characters!

(yes, there are other requirements for a string to be a valid channel name, such as absence of spaces or commas, but you have to check for those anyway)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Code:
alias test {
set %test 0
echo -a . $iif(%test = $null,Is,Isn't) Null
unset %test
}


Maybe this will explain better.
0 = $null

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Have you actually tried that code? It echoes "isn't null", as it should. I don't see where you got the idea that 0 is equivalent to $null because it's not. You may have been thinking of
Code:
if (!something)
which succeeds if something is either $null, 0 or $false.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Dunno, I haven;t had a mirc in front of me for months. 0 always acted as a null value in a variable for me.

Joined: Nov 2009
Posts: 117
Vogon poet
Offline
Vogon poet
Joined: Nov 2009
Posts: 117

//echo zero $iif(0 = $null,is,is not) null
zero is not null

$null $false $chr(0) 0 and nothing will all evaluate as false.

In other words, 0 and $null will both evaluate false but 0 does not equal $null

Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
$null = empty

but 0 is a value



WorldDMT

Link Copied to Clipboard