Difference between revisions of "Category:Hash Table"

From Scriptwiki
Jump to: navigation, search
 
(first try)
Line 1: Line 1:
 
+
== Basic Defintion ==
 +
Basically, hash tables are like [[:Category:Ini|ini files]], storing information in following format:
 +
 
 +
<b>Tablename</b><br />
 +
item1=data1<br />
 +
item2=data2<br />
 +
...
 +
 
 +
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|/hmake]], respectivly delete one using the [[Hfree|/hfree]] command. Using [[Hdel|/hdel]] and [[Hadd|/hadd]], you can modify the data saved in your hashtable. Due to hash tables not being automatically saved, you have to use the [[Hsave|/hsave]] and [[Hload|/hload]] command.
 +
 
 +
=== Receiving data ===
 +
After saving data in hash tables, you can of course receive them. Therefor, use the [[$hget]] and [[$hfind]] identifiers.
 +
 
 +
 
 +
 
  
 
[[Category:MIRC Help]]
 
[[Category:MIRC Help]]

Revision as of 16:10, 14 December 2005

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.