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:
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:
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
}