mIRC Home    About    Download    Register    News    Help

Print Thread
#271303 09/02/23 07:35 AM
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Currently, in order to find out which connection the $active is in, a script needs to loop through them all until it finds a match for $cid.

It would be more straightforward if either there was a $con equivalent to $cid, or else if $scon(N) or $scon(N).identifier returned for the active connection for N being -1

Code
alias con { var %i 1 | !while ($scon(%i).cid != $cid) !inc %i | !return %i }

Joined: Nov 2004
Posts: 842
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 842
I support this.

I use this, though.

Code
$findtok($regsubex($str(.,$scon(0)),/./g,$+($iif($scon(\n).cid == $activecid,1,0),.)),1,46)


What do you do at the end of the world? Are you busy? Will you save us?
Jigsy #271309 10/02/23 03:02 PM
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Just curious: in which kinds of situations do either of you prefer having the $con value over $cid ? I always though $cid fundamentally allows one to do the same things, but with the added benefit of stability across status window closes over time?


Saturn, QuakeNet staff
Sat #271331 16/02/23 11:26 AM
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
My current usage for $con is for a script that combines the output for all networks into a single @debug window with each line having a header telling the time in milliseconds and that this was the Nth connection, which is more useful (and shorter) than telling me this is connection ID#14556.

[09:35:21.608][6][DALnet] -> rangers.ix.us.dal.net PING :TIMEOUTCHECK
[09:35:21.626][6][DALnet] <- :rangers.ix.us.dal.net PONG rangers.ix.us.dal.net :TIMEOUTCHECK

So to get these 2 values, I'm currently needing to calculate them using 2 different aliases. To get the Nth connection, I needed to use the $con alias I described earlier. The timestamp here is a work-in-progress, and comes from:

alias fakestamp { return $+([,$time($ctime),.,$right($ticksqpc,3),]) }

As for Jigsy's alias, it does work too, but it benchmarks about 3x slower than mine because of the calls to $regsubex and $iif and $findtok. The total time fluctuates depending on how many connections you have open, but for this example while having 7 connections open, I'm getting around 400ms for Jigsy's command and around 140ms for mine

//var %j 999 , %t $ticksqpc | !while (%j) { var %con $findtok($regsubex($str(.,$scon(0)),/./g,$+($iif($scon(\n).cid == $activecid,1,0),.)),1,46) | !dec %j } | !echo -a time $calc($ticksqpc - %t) con: %con

//var %j 999 , %t $ticksqpc | !while (%j) { var %con 1 | !while ($scon(%con).cid != $cid) { !inc %con } | !dec %j } | !echo -a time $calc($ticksqpc - %t) con: %con

Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Quote
15.Extended $scon()/$scid() to support -1 for active connection.

//echo -a $scid(-1) = $scon(-1) = $cid

$scon(-1) and $scid(-1) are both behaving as duplicates of $cid, though the suggestion was that $con or $scon(-1) indicate the active connection is the Nth connection.

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Ah, right, I misunderstood. This has been changed to return the Nth position in the next beta.


Link Copied to Clipboard