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