mIRC Home    About    Download    Register    News    Help

Print Thread
Access list of server groups/networks? #238519 04/08/12 11:36 AM
Joined: Aug 2012
Posts: 4
R
RytoEX Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Aug 2012
Posts: 4
I've been searching around, but I haven't found an answer to this, so I thought I'd check here.

Is there an easy readily-available way to get a list of the server groups/networks (such as those that appear in "Options > Connect > Servers > IRC Servers" or "Options > Connect > Options > Perform... > Network" or "Options > Connect > Options > Perform... > Add")? Or must this be done in a programmatic fashion?

Thanks!

Re: Access list of server groups/networks? [Re: RytoEX] #238543 07/08/12 02:34 AM
Joined: Jun 2003
Posts: 994
C
CtrlAltDel Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994


I refuse to engage in a battle of wits with an unarmed person. wink
Re: Access list of server groups/networks? [Re: CtrlAltDel] #238545 07/08/12 06:45 AM
Joined: Aug 2012
Posts: 4
R
RytoEX Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Aug 2012
Posts: 4
Perhaps I should have provided a bit more information. I know that the servers.ini file exists and what it contains. I've also done a fair bit of reading of both the online mIRC FAQ and the help file that comes with the installation of mIRC (mirc.chm), but I realize that my lack of experience with mIRC means that I may have missed something. What I was looking for was something akin to $server(N) where I don't have to do any of my own string parsing from the servers.ini file.

Since I assumed that there was no such "easy way", I went ahead and wrote a script for it. I've never done any scripting work with mIRC before, so there might be better ways to go about this than what I did.
Code:
/getservergroups {
  ; Build a list of Groups/Networks from the server list in servers.ini and store in groups.ini
  ; Group/Network names can contain alpha-num, hyphens, and periods (and maybe more).
  if ($isfile(groups.ini)) {
    /remini groups.ini groups
  }
  %server_count = $server(0)
  var %group
  var %groups
  var %server
  var %sep = $asc(;)
  var %i = 0
  while (%i < %server_count) {
    %server = $readini(servers.ini, n, servers, n $+ %i )
    %group = $regex(%server, GROUP:(.+))
    %groups = $addtok(%groups,$regml(1),%sep)
    inc %i
  }

  %groups = $sorttok(%groups,%sep,a)
  var %num_groups = $numtok(%groups,%sep)
  %i = 1
  while (%i <= %num_groups) {
    /writeini -n groups.ini groups n $+ $calc(%i - 1) $gettok(%groups,%i,%sep)
    inc %i
  }
}

Re: Access list of server groups/networks? [Re: RytoEX] #238547 07/08/12 06:50 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Are you sure you read the full /help on $server()?

$server(N).group does what you want:

Code:
//echo -a $server(1).group


Loop through them all to enumerate all the networks. You'll obviously want to ignore duplicate groups, but $addtok will do this for you, and you already seem to know how to do that:

Code:
; use with //echo -a $networks
alias networks {
  var %i = 1, %max = $server(0), %groups
  while (%i < %max) {
    %groups = $addtok(%groups,$server(%i).group,32)
    inc %i
  }
  return %groups
}


I'm assuming you have less than 4096bytes worth of network data, otherwise you'll need to write it to a file instead.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Access list of server groups/networks? [Re: argv0] #238550 07/08/12 09:18 AM
Joined: Aug 2012
Posts: 4
R
RytoEX Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Aug 2012
Posts: 4
I've read the help quite a bit actually. I've been primarily referencing the in-application help though, so I don't often turn to the online help pages. And now after re-reading both again several times, I see why I missed it.
From mirc.chm (using mIRC 7.25):
Quote:
$server
Returns the name of the server to which you are currently connected.

If you are not currently connected to a server, it returns $null.

$server(N/address)
Returns the address of the Nth server in your irc servers list.

Properties: desc, port, group, pass

$server(0) returns the total number of servers in the servers list
$server(2) returns the address of the 2nd server
$server(2).desc returns the description of the 2nd server
$server(3).port returns the port(s) of the 3rd server

If you specify an irc server address and it is in your servers list, it returns its associated info.

$server(N).group is listed in "Properties", but then isn't described in the section immediately following. I probably skimmed right over the "Properties" list and just read the descriptions of .desc and .port below it. Though it may seem unnecessary, there should probably be descriptions for .group and .pass in that documentation as well.

On another pass of the online mIRC FAQ Section 7, I did find this:
Quote:
$server(N|nick) for the address, .desc for the description, .port for the port, .group for the group.

Still, I really should've seen that as I've been through that section multiple times, and I even quoted that segment in another thread on documentation inconsistency. =/ (Interestingly, .pass isn't listed in the online section.)

Ah well, at least I learned how the $regex and $regml commands work doing it the hard way. Positive thinking!

The groups.ini file I ended up from a default mIRC installation with is 2952 bytes, after ini line and group labels and CRLFs. While it seems to me that someone would have to add quite a few of extra networks to jump over the 4096 byte mark, I decided I'd write the data to an ini file to avoid the problem should it occur.

I'll try to read more carefully next time, and perhaps not so late at night. Thanks for your help!