mIRC Home    About    Download    Register    News    Help

Print Thread
#115434 26/03/05 03:18 AM
Joined: Mar 2005
Posts: 7
T
tabby Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2005
Posts: 7
Ok, my mIRC bot i am making a 'news service' type thing, in a hash table 'news' i have

$ctime news:information
$ctime news:inforamtion
$ctime news:information

etc. Because hash tables are like they are, when i go to output the data ie /msg mybot newslist i obviously want to list it in order of date sent so i do a loop of the hash table, and wack every item into a %var ie

$ctime:$ctime:$ctime:$ctime

then i use $sorttok on the %var and then do a loop on the %var to get the right time etc.

BUT when there is 60 or more im getting * set line too long ... is there any other way i can make it work or make a sorting process that will kinda work exactly the same that will allow me to have like up to well like 500 or something smirk

Thankyou!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#115435 26/03/05 03:23 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
You can dump everything into an @window opened with the -s switch and the data will be automatically sorted. Just make sure you use /aline and not /echo to add the data.


New username: hixxy
#115436 26/03/05 03:56 AM
Joined: Mar 2005
Posts: 7
T
tabby Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2005
Posts: 7
Silly me, i'll tell you how it goes :-)

#115437 26/03/05 04:03 AM
Joined: Mar 2005
Posts: 7
T
tabby Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2005
Posts: 7
hmmm

/window -s @news
/aline @news 1
/aline @news 20
/aline @news 5

in the window:

1
20
5

doesn't seem to sort it :-\

#115438 26/03/05 05:04 AM
Joined: Mar 2004
Posts: 175
Vogon poet
Offline
Vogon poet
Joined: Mar 2004
Posts: 175
The -s switch sorts the window alphabetically, not numerically. Thus, you will have to use /filter to alphabetically and numerically sort the window.

Code:
/filter -ctu 1 32 @news @news


- Relinsquish
#115439 26/03/05 05:31 AM
Joined: Mar 2005
Posts: 7
T
tabby Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2005
Posts: 7
i just used

/filter -a @news @news1 routine_filter

alias routine_filter { return $iif($1 > $2,1,$iif($1 < $2,-1,0)) }

probably did the long way ? :-)

#115440 26/03/05 05:39 AM
Joined: Mar 2004
Posts: 175
Vogon poet
Offline
Vogon poet
Joined: Mar 2004
Posts: 175
The -tu switches are a lot faster than calling an alias to sort the lines. The command I showed you should work without any problems.


- Relinsquish
#115441 26/03/05 07:31 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
This well be fine for his application

/window -s @news

$ctime is a 10 digit number and has been for some time

#115442 26/03/05 01:02 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Yep, the -s switch to sort $ctime values will be fine for a good few years :[/b]o)


New username: hixxy
#115443 26/03/05 02:17 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Is there a reason why you're not just using sequence numbers? Something like this:

alias news_init {
hmake news 10
set %news.lb 1
set %news.ub 1
}
alias news_addentry {
inc %news.ub
hadd news %news.ub $ctime $1- (whatever you want to enter)
}
alias news_remove_oldest_entry {
hdel news %news.lb
inc %news.lb
}
alias news_list {
var %k = %news.lb
while (%k <= %n) {
var %news = $hget(news,%k)
echo @newswindow Time: $gettok(%news,1,32) Text: $gettok(%news,2-,32)
inc %k
}
}

No need to sort stuff each time you need to send or display the news items. Only bad points: putting a news item in between is not easy (requires all following news entries to be moved) and searching on $ctime is somewhat more time-consuming, use $hfind(news,$ctime *,1,w).data to get the correct sequence number.

I've used global %variables for lower and upper bound, you can also put them in the hash table itself ofcourse...


Link Copied to Clipboard