figured i would post here first to see if anyone can help before i list it as a possible bug.
if (!$hget(optotal)) { hmake optotal 5 }
; if optotal table doesnt exist, make
set -u30 %oftotco1 1
set -u30 %oftotco2 $hfind(opts,*!*@*.*.*,0,w)
;prep loop parameters, second being the total wild entries in opts
while (%oftotco1 <= %oftotco2) {
set -u5 %opmsks $hfind(opts,*!*@*.*.*,%oftotco1,w)
echo -s %oftotco1 <= %oftotco2 && opts $opretnick(%opmsks) --- %opmsks ^^ $gettok($gettok(%opmsks,2 ,64),1, 46) ~~ %opmsks
; set %opmsks as entry (needed for retrieving nickname to add up the timestamps)
;echo the loop progess and table look up command, the match returned and the nickname returned from %opmsks
if ($hget(optotal,$opretnick(%opmsks))) {
//hadd opts $opretnick(%opmsks) $+ temp $hget(optotal,$opretnick(%opmsks))
//hdel optotal $opretnick(%opmsks)
; if optotal table nickname exists, set it as new value temp and delete the saved one
//hadd opts $opretnick(%opmsks) $+ min $calc( $gettok($hget(opts,$opretnick(%opmsks) $+ temp),2,58) + $gettok($otcalc3(%opmsks),2,58) )
; retrieve the mins saved from previous session then add mins from this session to it.
if ($hget(opts,$opretnick(%opmsks) $+ min) <= 59) {
//hadd opts $opretnick(%opmsks) $+ hrs $calc( $gettok($hget(opts,$opretnick(%opmsks) $+ temp),1,58) + $gettok($otcalc3(%opmsks),1,58) ) $+ :
if ($len($hget(opts,$opretnick(%opmsks) $+ min)) == 1) { //hadd optotal $opretnick(%opmsks) $hget(opts,$opretnick(%opmsks) $+ hrs) $+ 0 $+ $hget(opts,$opretnick(%opmsks) $+ min) }
; if the new value is 59 or less (mins) add the hours of saved sessions and this session together. if the mins lengh is 1 meaning 1 min to 9 mins, add 0 infront so it returns 0X minutes.
; else the mins returned as XX and no 0 is required so just add to optotal table
else { //hadd optotal $opretnick(%opmsks) $hget(opts,$opretnick(%opmsks) $+ hrs) $+ $hget(opts,$opretnick(%opmsks) $+ min) }
}
else {
//hadd opts $opretnick(%opmsks) $+ min $calc( $hget(opts,$opretnick(%opmsks) $+ min) - 60 )
//hadd opts $opretnick(%opmsks) $+ hrs $calc( 1 + $gettok($hget(opts,$opretnick(%opmsks) $+ temp),1,58) + $gettok($otcalc3(%opmsks),1,58) ) $+ :
//hadd optotal $opretnick(%opmsks) $hget(opts,$opretnick(%opmsks) $+ hrs) $+ $hget(opts,$opretnick(%opmsks) $+ min)
; else the minutes combined were 60 or more (meaning more than 1 hour) we need to remove 60mins, add 1 to the hours to compensate then add the left over mins from subtraction to the saved mins to form the new mins total.
}
//hdel opts $opretnick(%opmsks) $+ hrs
//hdel opts $opretnick(%opmsks) $+ min
//hdel opts $opretnick(%opmsks) $+ temp
; delete all hash stuff relating to the working out times.
}
if (!$hget(optotal,$opretnick(%opmsks))) { //hadd optotal $opretnick(%opmsks) $otcalc3(%opmsks) }
if ($hget(opts, %opmsks)) { //hdel opts %opmsks }
//hsave optotal optotal.hsh
inc -u30 %oftotco1
; if it didnt exist, just add the entry from alias otcalc3 - if opts entry still exists, delete to start new, save the table for precaution inc loop vari to start again
}
alias -l opretnick { return $gettok($gettok($1, 2,64),1,46) }
alias -l otcalc3 { return $duration($calc( $gmt - $hget(opts,$1)),3) }
output now showed as:
1 <= 8 && opts nick1 --- *!*@nick1.vhost.come ^^ nick1 ~~ *!*@nick1.vhost.com
2 <= 8 && opts nick2 --- *!*@nick2.vhost.com ^^ nick2 ~~ *!*@nick2.vhost.com
3 <= 8 && opts nick3 --- *!*@nick3.vhost.com ^^ nick3 ~~ *!*@nick3.vhost.com
4 <= 8 && opts nick4 --- *!*@nick4.vhost.com ^^ nick4 ~~ *!*@nick4.vhost.com
5 <= 8 && opts --- ^^ ~~
6 <= 8 && opts --- ^^ ~~
7 <= 8 && opts --- ^^ ~~
8 <= 8 && opts --- ^^ ~~
After editing some suggestions made by argv0 - it still failed on the hfind, ive added comments into it so coders can read what its meant to be doing.
Last edited by Desolator; 27/12/11 10:48 PM.