The "problem" (in terms of possible options) with your current structure is that you store the data acc. to:
hash table item: nick
hash table data: nick,address,IP,eMail
therefore, a /hsave -i produces: nick=nick,address,IP,eMail
As you see, the data isn't separated by the same char ("=") which would be "perfect" for /filter -t. On the other hand side it's OK in this case, and "=" may be part of email addresses... Sorting the $chr(44)-separated column 1 works none the less.

Because you want to "dump" the whole hash table here, hsave -i should work better (faster) than a while loop through all hash table items like:
Code:
while $hget(%t, %i).item != $null { 
  aline @test $hget(%t, $v1) $crlf $crlf
  inc %i
}

...just get rid of the dump-file after creating the "final" file. smile

A hidden window may be the better choice IF you're scanning for specific items in the hash table ($hfind > aline). And IF there actually would be multiple filter/search operations to do, a dumped file might catch up again: as you could perform multiple /filter commands on the same source file. But again, this isn't the case here.

The code below is more or less an alternative version of your code, maybe you like one or two details of it.

Code:
; usage: /listinfo [nick|address|IP|mail]

alias listinfo {
  if ($findtok(nick address IP mail,$1,32)) { var %column = $v1 }
  else { echo -a Syntax: /info [nick|address|IP|mail] | return }

  if (!$hget(ipinfo,1).item) { echo -a table "ipinfo" is empty. }
  else {
    ; $mircdir, to ensure write permission on all systems. $qt to play safe with spaces in folder names.
    var %tempfile = $qt($+($mircdir,IPinfoDump.txt)), %outfile = $qt($+($mircdir,Report_IPInfo.txt)), %n = 1

    ; dump table to tempfile (write -c to ensure an empty tempfile)
    write -c %tempfile
    hsave -i ipinfo %tempfile
    ; sort data in tempfile
    write -dl1 %tempfile
    filter -ffct %column 44 %tempfile %tempfile

    ; heading lines of outfile
    write -c %outfile Report runtime: $+($asctime(ddd mmm dd @ HH:nn:ss),.) There are $lines(%tempfile) item(s) listed.
    write %outfile Report compiled by: $replace($1,ip,IP address,mail,E-mail) 
    write %outfile $str(-,30) $crlf $crlf

    ; for the "show the sort-by column in first place" idea
    var %denote = Nick: Address: IP: eMail:

    ; loop lines of tempfile
    while ($read(%tempfile,%n)) {
      var %read = $gettok($v1,2-,61), %line, %t = 1
      ; insert denotations
      while ($gettok(%read,%t,44)) {
        var %line = $addtok(%line,$gettok(%denote,%t,32) $v1,44)
        inc %t
      }
      ; write data to outfile; sortby-column in first place
      tokenize 44 $deltok(%line,%column,44)
      write %outfile $gettok(%line,%column,44) >>> $1- $crlf $crlf
      inc %n
    }

    ; remove the tempfile and run the outfile
    .remove %tempfile
    run %outfile

  }
}


Note that the while loop (performing multiple /write operations) can be accelerated using "file handlers", but that's a different story and only importand if your dataset is huge.

Last edited by Horstl; 15/11/08 05:08 AM.