mIRC Homepage
My Bot is really coming together now, but after speaking with a few other pug bot authors most of them are using tokens. Basically all the bot really does it maintain nick lists of ppl that type certain commands, 10 items at most in each array.

I've read a lot on hash tables so I think I have a good working understanding of them, but what exactly is the benefit of tokens? I can see from the syntax they would easy to play with the data, but in terms of speed which is faster? Which do you recommend? Thoughts, comments?

Any extra information on the topic would be greatly appreciated, also sorry if I posted this in the wrong thread!
From what you are saying, you are comparing a data type with a storage type. By that i mean you are trying to compare something that stores info, with the way it maintains the info in that storage space.

Hash tables are almost always fast, and extremly efficient when it comes to large amount of data. You can also combine the hash tables with the token storage type. i.e.
/hadd table Item1 abcd,efg,hijk,lmnop,qrs

$gettok($hget($table,Item1),2,32) would return efg.
Agreeing with what KingTomato said, I'll also add that you
may as well compare apples and oranges. I recall what it
was like before and truthfully, I can't imagine life without
token identifiers lol, but then maybe that's just me.
Thanks for the comments boys!

So in terms of effiency, I know from Perl that splits are not regarded as the best way of doing things, which is what a token basically looks like (correct me if I'm wrong), in terms of data access (retreiving an item from the list so to speak) which is faster?

Also what kind of limitations do you have on tokens? Can any ASCII character go into a token? Do they have a size limit? When you reach what limit do hash tables become a necessity?

Which do you prefer? Why? Do I even need to bother with these as I have it coded in hash tables already or is this subject something I could benefit from?

Thanks again!!!
the two things are totally different,
A hash table is esentially an array, but instead of a dimension from 0 to n or even 0 to infinite, it uses symbols to identify each array element, I also dont think they remain in the order u make em (not sure on that)
/hadd tablename 1 fred was here
/hadd tablename 2 bill left today
/hadd tablename G jill is missing
^ thats 3 array entries tablename(1), tablename(2), and tablename(G) [as you can see you dont have to use just numbers]

now tokens are something differnet, and i think your only seeing them from the simplest of views such as
var %tablename fred was here ! bill left today ! jill is missing
$gettok(%tablename,2,$asc(!)) < 33 is of course ! and thats the seperator I used here)

heres what you might uses tokens for
[ $1 = <- :Motorolan!~me@53886e8.10eff834.1377149a.36cd2766.IP PRIVMSG #blah :i am here ]
echo $gettok($gettok($1,1,$asc(!)),2,$asc(:)) just did a $gettok($1,3,32)

your result would be
Motorolan just did a PRIVMSG #blah :i am here

breaking it down $gettok($1,1,$asc(!)) gets "<- :Motorolan"
then $gettok(<- :Motorolan,2,$asc(:)) gets "Motorolan"

As u can see tokens are not just used to create small arrays of values, but rather can be used for a multitude of things.

Thanks! Thats exactly what I needed. Oh and hash tables do stay in the index you add them, I'm pretty efficent with them now. From your description of tokens I can totally see that a mixture is what I need, I can see really good uses for both.

Thanks for the great post I really appreciate it!!

One last question, is there anyway to use other things then ASCII values like regular expressions as your separator?
One last question, is there anyway to use other things then ASCII values like regular expressions as your separator?

No sorry, a token seperator is just a asc value in the text used as the seperator, of course you could uses a identerfier alias that returns the asc value of the seperator, and in that alais is the regex that isolates it, but im not sure if thats what you really ment as the seperator.

I also used to find it anoying if the seperator i wanted was more than one character, untill i thought a little laterally and used something like this.

%t = delta.txt ~~ alpha.bat ~~ Gamma.exe
$gettok($replace(%t, $+($chr(32),~~,$chr(32)),>),2,$asc(>))

replace " ~~ " with ">" [i use > as it cant be in a filename]

I also dont normally use $asc(>) but would just put the 62 in.
© mIRC Discussion Forums