Category:Hash Table

From Scriptwiki
Revision as of 16:16, 14 December 2005 by Doomie (talk | contribs)

Jump to: navigation, search

Basic Defintion

Basically, hash tables are like ini files, storing information in following format:

Tablename
item1=data1
item2=data2
...

However, hash tables are a lot faster than ini- or text-files, which especially takes effect if you have a lot of entries. A kind of disadvantage is the missing possibility to see all entries. With some files, you can just open them and take a look on every entry, whereat hash table, you can't just open then. To have the chance to still get an overview, you can use the following script:

; lets make a little alias called showhash. At the end, it will look like /showhash <name>
alias showhash {
 ; echo the name and a kind of "table header"
 echo -a $1
 echo -a item => data
 var %i = 1
 ; lets loop through all items. $hget($1,0).item will return the total amount of items.
 while (%i <= $hget($1,0).item) {
  echo -a $hget($1,%i).item => $hget($1,%i).data
  ; increase looping-variable
  inc %i
 } 
}

Modifying hash tables

You can make a new hashtable using the /hmake, respectivly delete one using the /hfree command. Using /hdel and /hadd, you can modify the data saved in your hashtable. Due to hash tables not being automatically saved, you have to use the /hsave and /hload command.

Receiving data

After saving data in hash tables, you can of course receive them. Therefor, use the $hget and $hfind identifiers.

Pages in category "Hash Table"

The following 10 pages are in this category, out of 10 total.