mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
Ok basically im looking to see if someone can script some identifiers for me, i can do them but there not that efficient and im sure it can be done a better way.

What im looking to do is make token identifiers that allow you to deal with sub items in hash tables and ini tables, mostly hash but there the same format so w/e blush.

The sub items would be very simple, in this example were using a character seperator #39 which is '.

Item=SubItem=Value'SubItem2=Value'SubItem3=Value

Im looking for general token idents, best i can come up with is like wild token searching and junk, which seems like a horrible way to go about it. Anyone know of a good way to get what i want done? Thx!

Joined: Dec 2002
Posts: 271
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
Any reason why you cant Give each item a section in an ini file or its own hash table. For example, you need an item named Item1, and it needs subitems with values, then just create a section in ini format name [Item1], or create a table named Item1. Then you can store items and values in that section(ini) or table(hash).

[Item1]
Item1=value1
Item2=value2
etc

Same Theory as above for hash tables



Those are all Subitems, With Their Values, of either [Section] or table... which is what you need, is it not?

Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
because its a waste of space, im already ganna have 500 hash tables, and 60ish items in that specific hash table im coding this specificly for (though im sure i'll use the subitem in more places than this). So if i did it like
[Table]
Item1_Blah=Value
Item1_Blah2=Value there will be a ton of items. This is all done for neatness and space. And the reason im using hash is because its faster.

Iv already coded the two i needed so far, a hget read and a addtok "$addtok_sub(text,subitem,token,character)" and a read "$hget_sub(table,item,subitem,character)" but im just wondering if it can be done faster, better, ect.

Joined: Dec 2002
Posts: 271
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
To me it seems like your trying to recreate some functionality that has already been provided to us via hash tables/ini files. for what you are doing there probably isnt a faster way then $gettok or tokenize besides using the already provided methods. i dont think it matters how many tables you have, just whenever you need to read from them, re-create and load the tables, then close them, with an alias maybe, and that would be the fastest way of doing it.

Example:

echo -a $DoHashRead(sometable,someitem)


alias DoHashRead {
if (!$2) { echo 4 -s Error Reading Hash Table - Insuficient Parameters! | return }
hmake $1 <size>
hload $1 <file>
var %info = $hget($1,$2)
hfree $1
return %info
}

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

don't worry about the number of items you can use in a hash table. Use a million, it doesn't really matter (cept if you're really lacking ram), it'll still be very fast.

Btw you were probably misinformed, because hash tables are nothing like .ini files. You are referring to a saved hash table in .ini format (/hsave with i flag) I suppose, but then that's not a hash table anymore, but a saved representation of it in .ini form. Not the same thing.

500 hash tables is seriously redundant, and 60 items in a hash table is nothing. Some people keep thousands of entries in a hash table.

There are better ways to organize your data. Perhaps you could check out mIRC Scripts and check out one of the "Hash Table" tutorials, because I kinda get the feeling that you are using them inefficiently.

Greets

Last edited by FiberOPtics; 28/08/04 03:54 PM.

Gone.
Joined: Dec 2002
Posts: 271
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
100% agreed

Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
its not about the speed at which the hash tables preform its the clutter that it creates, i try not to clutter my tables with useless items. If the item values are ganna be huge then sure, i give them an item, otherwise i use the method im talkin about.

And about ini and hash tables being the same, i mean format wise. Its still Group, Item Value. May be called dif things but thats what it is. Cept with ini you get another step if you will, File, Group, Item, Value.


My whole reasoning behind this is that i dont want xxxxx amount of items in a hash table that i may need to read through, i like it sorted nice and easy. Anyway.. thanks.

Btw i went through the same thing at
http://www.mircscripts.org/forums.php?cid=3&id=102402#102402
lol



*edit*

And in replies to me using the hash tables inefficiently, basically theres a MuD made, with thousands of room and its been in hash form for a while. This discussion about sub items was just to see if someone could code one more efficiently than me which the saubject is going in discussion at mircscripts.org but none the less its for basically info tracking, almost the same as variables in a sence.

The MuD has a table for each room and each table is small but i just did it that way, i could use my method im talkin about above or the way i thought about doing it way back when which is like Table, Item_SubItem=Value

That would take the thousands of rooms, put it into one hash, but for every room you would have anywhere from 10-20+ items, so overall i found just making tables for each more effective. It used to be in ini form but overall im liking it in hash form more.

Last edited by Zeusbwr; 29/08/04 06:14 AM.

Link Copied to Clipboard