Difference between revisions of "Category:Hash Table"

From Scriptwiki
Jump to: navigation, search
(first try)
Line 10: Line 10:
  
 
  ; lets make a little alias called ''showhash''. At the end, it will look like ''/showhash <name>''
 
  ; lets make a little alias called ''showhash''. At the end, it will look like ''/showhash <name>''
  alias showhash {
+
  [[alias]] showhash {
 
   ; echo the name and a kind of "table header"
 
   ; echo the name and a kind of "table header"
   echo -a $1
+
   [[echo]] -a $1
 
   echo -a item => data
 
   echo -a item => data
 
   [[var]] %i = 1
 
   [[var]] %i = 1
Line 19: Line 19:
 
   echo -a $hget($1,%i).item => $hget($1,%i).data
 
   echo -a $hget($1,%i).item => $hget($1,%i).data
 
   ; increase looping-variable
 
   ; increase looping-variable
   inc %i
+
   [[inc]] %i
 
   }  
 
   }  
 
  }
 
  }

Revision as of 17:16, 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.