$scon
From Scriptwiki
Returns the connection id, where N is the Nth connection.
$scon(N)[.id]
Note that if you specify N = 0, $scon returns total number of open server windows.
If you specify a property which is an identifier, it returns the value of that identifier for that connection. This also works for custom identifiers (see examples).
Note that you cannot use identifiers with brackets (e.g. $asctime(dd)). As workaround, you could make a custom alias returning this value.
Examples
var %i = 1 while ($scon(%i)) { echo -a $scon(%i).network inc %i }
This example would loop through all open server windows and echo the network name. Note that .network is the $network identifier for this special connection. You could also /scon to the connection and echo $network.