Well, to make one use
/hmake <name> <size>

the size is generall the square root of how many items you expct to have. For example if you expect to have 100 items, 10 is fine. So lets say we're storing acronyms for chatting. 100, is a good number, so we'll use 10

Code:
/hmake acronym 10


Okat, so now we have the hash table, now we want to add some items. Here is where /hadd come in. You simply type /hadd <hash_table> <value_name> <value>. So for example, lets add a few acrnyms to our hash table..

Code:
/hadd acronym afk Away From Keyboard
/hadd acronym brb Be Right Back
/hadd acronym lol Laughing Out Loud
/hadd acronym ttyl Talk To You Later


Okay, so not we have a had table, and four values. Now, we have the data but how do we use it? Well, for this example lets just use a simple on input event. We will take the user's input, look for our acronyms, and then replace as needed.

For matching and checking a value exists in the has table, we use $hget(hash_table, value_name) (And just $hget(<hash_table>) to see if the table exists). If it returns a value, the item is set, otherwise no value exists. Lets cycle through the words

Code:
on *:INPUT:#: {
  if ($left($1, 1) !isin $+(/,$readini($mircini,text,commandchar))) {
    ; check if the hashtable exists
    if ($hget(acronym)) {
      var %w = 1, %word, %msg
      while (%gettok($1-, %w, 32)) {
        %word = $ifmatch
        if ($hget(acronym, %word)) %text = %text $+([,$ifmatch,])
        else %text = %text %word
        /inc %w
      }
      /msg $active %msg
      /halt
    }
  }
}


Okay, so now we went through each word, found any and all matching words, and replaced them. Now, the message shoudld be like this:

Input: that was a funny joke, lol
Output: that was a funny joke, [Laughing Out Loud]

Okay, now we have all the information, but how do we save it? Well, now we get to /hsave and /hload, which will save and load our table respectivly. Okay, so say we want all the acronyms save to a file called acronyms.hsh when we close mirc. To do this, we use on EXIT, and the hsave command.

Code:
on *:EXIT: {
  ; if our table exists (was created)
  if ($hget(acronym)) {
    ; save it (-o means overwrite existing file (we don't need it anymore))
    /hsave -o acronym acronyms.hsh
  }
}


Okay, so now we made our table, we added information, we used the table and saved it--now what. Well, now what we do is load it on our next running of tribes. For this we look at on start.

Code:
on 1:START: {
  ; intialize hash table
  /hmake acronym 10
  ; now, if the file we want to load from existsa, load it..
  if ($isFile(acronyms.txt)) /hload acronym acronyms.hsh
}


And there we go. Now we have a hash table that is used to replace acronyms. Its a simple script, but is a nice little beginner's starting point. Hope this helps, and if you have any questions, thats what the forums are here for!

grin


-KingTomato