mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 133
W
Vogon poet
OP Offline
Vogon poet
W
Joined: Jan 2004
Posts: 133
I have a hash table with lets say .. 50-100 dates ..

they are formated like:

Fred
4 years 6 months 28 days 7 hours 44 minutes 50 seconds

[greeg]
28 days 7 hours 44 minutes 50 seconds

-mark-
44 minutes 50 seconds
ect. ...

I want a script that will search the hash table
and find the oldest date from the list

in other words the longest time listed ...

LOL i cant do it ..
also would like a small script to take all the times listed and add them together for a total time of all data ...

but the first one is what i really need ..

HELP !?

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
It would help if you post a sample of how the data is stored in your hash table.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Jan 2004
Posts: 133
W
Vogon poet
OP Offline
Vogon poet
W
Joined: Jan 2004
Posts: 133
I am Using a script i found ..
by: Kelder
addict

HERE ..

I have two hash tables ..
one holds the times i started .. start-up-times- $+ $chan
and one that holds the uptimes .. up-times- $+ $chan

%oldinfo reads the > start-up-times- $+ $chan
%newtime > is the new time

var %fixit = $datediff(%oldinfo, %newtime,u)
/hadd -m up-times- $+ $chan $nick %fixit

up-times- $+ $chan < is the storage i nee to read and get the BEST time from

Last edited by WarlockW; 06/11/05 01:39 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Quote:
It would help if you post a sample of how the data is stored in your hash table.


He actually did... nick is the item, time is the data in his first post. As for sorting hash table item data, I'm not really sure the best way to do it. I'd be interested in seeing how as well.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
While I'm really glad my stuff gets used, it's not the best solution in this case..

var %fixit = $calc($ctime(%newtime) - $ctime(%oldinfo))

Now %fixit should contain the number of seconds that passed between those timestamps and you now just have to get the biggest number. That's going through the entire list checking each entry and keeping both the largest number yet and the item name where it was. To actually display the duration, either do the $datediff at that time if you can find both timestamps back, or add the $datediff after the number of seconds in %fixit and then use $gettok to get either the number of seconds or the human-readable format...

Joined: Jan 2004
Posts: 133
W
Vogon poet
OP Offline
Vogon poet
W
Joined: Jan 2004
Posts: 133
yes .. that would be better ..
sorry for the long time between replys ..

I still have not figured out how to get this working ..

But as Riamus2 Knows .. I am Not that great at this ..
but learning ... the hole check something store it .. loop
thing .. is beyound me lol

Format is ..

Fred
4 years 6 months 28 days 7 hours 44 minutes 50 seconds

[greeg]
28 days 7 hours 44 minutes 50 seconds

-mark-
44 minutes 50 seconds

This is what I can up with .. But it dont work lol

alias uptest {
//write -c high.txt
//write -c temptest.txt
var %i = 1
var %ii = 2
while (%ii <= $lines(Best-up-times-#channel.txt)) {
//write temptest.txt $read(test.txt,%i) $duration($replace($read(Best-up-times-#channel.txt,%ii), weeks,wks, week,wk, hours,hrs, hour,hr, minutes,mins, minute,min, seconds,secs, second,sec))
inc %i
inc %i
inc %ii
inc %ii
}
upfilter
}
alias upfilter {
var %o = 1
while (%o <= 5) {
var %high = 0
var %i = $lines(temptest.txt)
while (%i >= 1) {
if ($gettok($read(temptest.txt,%i),2,32) > %high) {
set %high.line %i
set %high $gettok($read(temptest.txt,%i),2,32)
}
dec %i
}
.write high.txt $read(temptest.txt,%high.line)
echo $active %high -- $read(temptest.txt,%high.line)
.write [ -dl $+ [ %high.line ] ] temptest.txt
inc %o
}
echo $me Top Five Highest Online Uptimes ...
echo $me 1. $gettok($read(high.txt,1),1,32) $duration($gettok($read(high.txt,1),2,32))
echo $me 2. $gettok($read(high.txt,2),1,32) $duration($gettok($read(high.txt,2),2,32))
echo $me 3. $gettok($read(high.txt,3),1,32) $duration($gettok($read(high.txt,3),2,32))
echo $me 4. $gettok($read(high.txt,4),1,32) $duration($gettok($read(high.txt,4),2,32))
echo $me 5. $gettok($read(high.txt,5),1,32) $duration($gettok($read(high.txt,5),2,32))
}


dso

Joined: Jan 2004
Posts: 133
W
Vogon poet
OP Offline
Vogon poet
W
Joined: Jan 2004
Posts: 133
well this is what i can up with .. with help ..

alias uptest {
var %i = 1
var %ii = 2
while (%ii <= $lines(Best-up-times.txt)) {
//write temptest.txt $read(Best-up-times.txt,%i) $duration($replace($read(Best-up-times.txt,%ii), weeks,wks, week,wk, hours,hrs, hour,hr, minutes,mins, minute,min, seconds,secs, second,sec))
inc %i
inc %i
inc %ii
inc %ii
}
upfilter
}

alias upfilter {
var %o = 1
while (%o <= 10) {
var %high = 0
var %i = $lines(temptest.txt)
while (%i >= 1) {
if ($gettok($read(temptest.txt,%i),2,32) > %high) {
set %high.line %i
set %high $gettok($read(temptest.txt,%i),2,32)
}

dec %i
}
.write high.txt $read(temptest.txt,%high.line)
;echo $active %high -- $read(temptest.txt,%high.line)
.write [ -dl $+ [ %high.line ] ] temptest.txt
inc %o
}
; fmsg %msgnetwork-test #test-chat
fmsg %msgnetwork-test #test11 .: Top 10 Best Uptimes 11:.
fmsg %msgnetwork-test #test11 1: $gettok($read(high.txt,1),1,32) 11- $duration($gettok($read(high.txt,1),2,32))
fmsg %msgnetwork-test #test 11 2: $gettok($read(high.txt,2),1,32) 11- $duration($gettok($read(high.txt,2),2,32))
fmsg %msgnetwork-test #test 11 3: $gettok($read(high.txt,3),1,32) 11- $duration($gettok($read(high.txt,3),2,32))
fmsg %msgnetwork-test #test 11 4: $gettok($read(high.txt,4),1,32) 11- $duration($gettok($read(high.txt,4),2,32))
fmsg %msgnetwork-test #test 11 5: $gettok($read(high.txt,5),1,32) 11- $duration($gettok($read(high.txt,5),2,32))
fmsg %msgnetwork-test #test 11 6: $gettok($read(high.txt,6),1,32) 11- $duration($gettok($read(high.txt,6),2,32))
fmsg %msgnetwork-test #test 11 7: $gettok($read(high.txt,7),1,32) 11- $duration($gettok($read(high.txt,7),2,32))
fmsg %msgnetwork-test #test 11 8: $gettok($read(high.txt,8),1,32) 11- $duration($gettok($read(high.txt,8),2,32))
fmsg %msgnetwork-test #test 11 9: $gettok($read(high.txt,9),1,32) 11- $duration($gettok($read(high.txt,9),2,32))
fmsg %msgnetwork-test #test 11 10: $gettok($read(high.txt,10),1,32) 11- $duration($gettok($read(high.txt,10),2,32))
.remove temptest.txt
.remove high.txt
}

on *:text:!bestuptime*:#test:{
uptest
}

It works .. but lags the heck out of .. mirc .. lol
thanks guys ..

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
If it's not too much trouble, you would really be better off completely changing how you store your uptime information. Do not store it as words... "5 days, 3 minutes, 2 seconds". Instead, store is in $ctime format rather than using $duration or $date or $time.

Note that you should probably put the temporary join time data into a hash table, then when they leave, you can use that to check the difference with the time they left and see if the time is larger than what is stored in the text file.

Then, when they leave (part/quit), you write the difference of $ctime - original $ctime.

This method will allow you to easily use /filter to find the top times.

Your text file will look something like this:

Nick1 23546
Nick2 457687
Nick3 123
Nick4 6544
Nick5 32454

After you use /filter to sort the data based on column 2, you can use $duration(time value) to get the time in weeks/months/etc. This will be very fast and easy and will not lag mIRC at all.

I'll consider writing up an example in a bit... though, you may want to try what I suggested on your own and see how far you can get.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard