mIRC Home    About    Download    Register    News    Help

Print Thread
$chan($active).mode #217555 16/01/10 01:37 AM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
$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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $chan($active).mode [Re: Wims] #217556 16/01/10 01:46 AM
Joined: Dec 2008
Posts: 95
A
asdfasdf Offline
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.

Re: $chan($active).mode [Re: asdfasdf] #217557 16/01/10 01:52 AM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
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.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $chan($active).mode [Re: asdfasdf] #217562 16/01/10 06:19 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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.

Re: $chan($active).mode [Re: Wims] #217570 16/01/10 09:03 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
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.

Re: $chan($active).mode [Re: DJ_Sol] #217577 17/01/10 04:52 AM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
$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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $chan($active).mode [Re: Wims] #217579 17/01/10 08:30 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
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

Re: $chan($active).mode [Re: DJ_Sol] #217646 18/01/10 08:40 PM
Joined: Feb 2009
Posts: 133
C
chacha Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
$null = 0 ?!
dont think!


WorldDMT
Re: $chan($active).mode [Re: chacha] #217655 19/01/10 01:32 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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.

Re: $chan($active).mode [Re: RusselB] #217658 19/01/10 04:09 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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.
Re: $chan($active).mode [Re: Horstl] #217659 19/01/10 07:10 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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.

Re: $chan($active).mode [Re: Horstl] #217665 19/01/10 12:59 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: $chan($active).mode [Re: qwerty] #217667 19/01/10 02:15 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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.
Re: $chan($active).mode [Re: Horstl] #217668 19/01/10 02:43 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: $chan($active).mode [Re: chacha] #217672 19/01/10 03:20 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
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

Re: $chan($active).mode [Re: DJ_Sol] #217673 19/01/10 03:28 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: $chan($active).mode [Re: qwerty] #217678 19/01/10 06:29 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
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.

Re: $chan($active).mode [Re: DJ_Sol] #217679 19/01/10 06:49 PM
Joined: Nov 2009
Posts: 117
gooshie Offline
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

Re: $chan($active).mode [Re: DJ_Sol] #217723 20/01/10 11:36 PM
Joined: Feb 2009
Posts: 133
C
chacha Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
$null = empty

but 0 is a value



WorldDMT