egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help with comparing two files...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
phab
Voice


Joined: 22 Aug 2005
Posts: 12

PostPosted: Thu Sep 08, 2005 6:59 pm    Post subject: Need help with comparing two files... Reply with quote

Hello guys.

I wrote something like a ranking (most active users).
I store them in a file which looks like:

01|phab
02|bot1
03|anotherone
04|nickname
05|sweety
...

I generate the stats each Sunday (for example). Now I want the bot to inform the channel with something like:

"Active Users v1.0: phab isn't place #1 anymore, nickname got him! phab is now on place 03. Sweety is more active than anotherone this week, too."

I hope you understand... I want to say which user is activer than the others and went up in my ranking.

Any ideas how I could handle this? At the moment I dont know... Sad

Please help!

Regards
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Thu Sep 08, 2005 7:17 pm    Post subject: Reply with quote

split them into a list like
[split $rankA \n] and [split $rankB \n]
after that you can compare them like
[lindex [split [lindex $rankA 0] |] 1] == [lindex [split [lindex $rankB 0] |] 1]
dont know if there is a more elegant way, maybe using it within a foreach loop compresses the code a bit.
if you have a missmatch, you can use lsearch to find the old/new rank.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
phab
Voice


Joined: 22 Aug 2005
Posts: 12

PostPosted: Fri Sep 09, 2005 2:35 am    Post subject: Reply with quote

Thank you. I'll give it a try! Smile

For other suggestions: Thanks! Smile
Back to top
View user's profile Send private message
phab
Voice


Joined: 22 Aug 2005
Posts: 12

PostPosted: Fri Sep 09, 2005 5:01 am    Post subject: Reply with quote

I can't get it working Sad

I read the old-ranking file till it's eof.. but i dont know how to compare the right way Sad

Any ideas?
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Sep 09, 2005 5:17 am    Post subject: Reply with quote

if your data is ordered by rank, there's no need of the first field

read the two files in 2 lists, then for each element of the first list compare its index to the same element's index in the second list (to find that index, use [lsearch])
Back to top
View user's profile Send private message Visit poster's website
phab
Voice


Joined: 22 Aug 2005
Posts: 12

PostPosted: Fri Sep 09, 2005 6:52 am    Post subject: Reply with quote

Thanks you. That's it ,-)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber