mIRC Home    About    Download    Register    News    Help

Print Thread
#114221 13/03/05 04:14 AM
Joined: Jul 2003
Posts: 37
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Jul 2003
Posts: 37
Using mIRC 6.14 on XP Pro
Not sure if this is a mIRC bug or lack of understanding on my part.

I am on 2 irc servers, and when i set away i get " * No such connection id: 2"

The aim is to cycle through the current connections and set away on each, but

Code:
//echo -s $scon(0) 
2 


the first connection is rightly mumbered 1
Code:
 //echo -s $cid
1  


Now if i switch to the only other connection, it says 3?
Code:
 //echo -s $cid
3


Since i have not been on a 3rd connection since starting mIRC i'd expect the 2nd connection to be 2 not 3?

Anyone know of a way to handle this? I cant loop for 1 to $scon(0) as that tries to switch to connection 2 which doesnt exist, instead of connection 3 confused

#114222 13/03/05 04:50 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Maybe try looping and on each loop check if $scid(loop #) is $null?

I realize that, in theory that shouldn't be possible, but then again, in theory, if you only have two sessions going, then they should be numbered 1 & 2, not 1 & 3.

#114223 13/03/05 07:38 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
You should always try things on the latest version of mIRC before reporting a bug since the bug you're reporting may of already been fixed.
$cid rightly returns 2 on my second connection in 6.16.

mIRC has the functionality you're looking for built-in:

Code:
scid -at1 away <message>


New username: hixxy
#114224 13/03/05 08:00 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
alias loopservers {
  var %i = 1
  echo -a Number of servers $scon(0)
  while (%i <= $scon(0)) {
    scon %i
    echo -a Server number $+(%i,'s) cid is $cid
    inc %i
  }
}

/loopservers
Number of servers 2
Server number 1's cid is 1
Server number 2's cid is 4


Were u using /SCID to change servers?
Using /SCID N to change to a specific server should only really be used when you already know the $cid of that server since $cid is the N value.

If your wanting to loop through each server use /SCON N it uses 1 to N for the server numbers, the $cid's well be set according to each connection, in my case the cids were 1 then 4.
Note. I had just started mirc, so i assume the $cid value is not always dependent on server connection order etc, but rather is a unique Conection IDentification number.

#114225 13/03/05 10:24 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
CIDs are just numbers that uniquely identify a session. They were never designed to be sequential, with no gaps among them. The only rule they must follow is that each session must have its own, unique CID. In reality, when you start up mirc, the Status window is assigned the CID 1. If you open a second Status, it gets the CID 2. If you then close that Status and open another one (so that the new one will be the second in list), it gets the CID 3 (as if mirc remembers how many Status windows have ever been opened). So in the above example, you end up with two Status windows, the one having CID 1 and the other CID 3.

It's now obvious that you can't loop through CIDs by incrementing a variable %i and using it for the CID. This is why $scon() and /scon were introduced. $scon(N) returns the CID for the Nth connection (that CID may very well be a number other than N). /scon N command performs the command on the Nth session, while /scid N command performs the command on the session with CID N.

So there are 2 ways to loop through all connections and do something on them. Either by incrementing a variable and passing it to /scon:
Code:
var %i = 1, %total = $scon(0)
while %i <= %total {
  scon %i
  echo -s This goes to the $ord(%i) Status Window
  inc %i
}

or by incrementing a variable, passing it to $scon(), then passing $scon() to /scid:
Code:
var %i = 1, %total = $scon(0), %cid
while %i <= %total {
  %cid = $scon(%i)
  scid %cid
  echo -s This goes to the $ord(%i) Status Window with CID %cid
  inc %i
}


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard