mIRC Homepage
Posted By: Skeletor Hash Tables - 03/11/08 08:58 PM
hey all,

I have been trying to slip stream my mIRC folder down a bit and I noticed that there are quite a few .hsh files. I have sorted out most of the .dll's and such, its just the hash table files.

On *:Start: {
  hmake ont
  hmake ond
  hmake ontond_targets
  hmake ontond_servers
  if ($isfile(ont.hsh)) hload -o ont ont.hsh
  if ($isfile(ond.hsh)) hload -o ond ond.hsh
  if ($isfile(ontond_targets)) hload -o ontond_targets ontond_targets.hsh
  if ($isfile(ond.hsh)) hload -o ontond_servers ontond_servers.hsh
  .enable #ontond_text
  .enable #ontond_action
  set %ontond_server off
  set %ontond_targets off

What is the best way to make them save to a folder ie "$mircdir/data/ond.hsh"

I have tried but nothing seems to work.

Posted By: Horstl Re: Hash Tables - 03/11/08 09:48 PM
Quick suggestion (untested)
I don't know what the -o switch should be for, though.
on *:start: {
  hashfiles load
  .enable #ontond_text
  .enable #ontond_action
  set -e %ontond_server off
  set -e %ontond_targets off

on *:exit: { hashfiles save }

alias hashfiles {
  var %dir = $mircdirData\
  var %tables = ont ond ontond_targets ontond_servers
  var %n = 1

  if ($1 == load) {
    while ($gettok(%tables,%n,32)) {
      var %table = $v1
      hmake %table
      if ($isfile($+(%dir,%table,.hsh))) { hload -b %table $qt($+(%dir,%table,.hsh)) }
      inc %n

  elseif ($1 == save) {
    while ($gettok(%tables,%n,32)) {
      var %table = $v1
      if ($hget(%table,1)) { hsave -b %table $qt($+(%dir,%table,.hsh)) }
      inc %n

As it's using an alias, you can e.g. trigger the "/hashfiles save" command every now and then (to reduce data loss by crashes or the like).
Saving/loading tables in binary format (-b switch) may speed up the load and save procedure; compared to -i (ini format) at least it's noticeable smile
Posted By: Skeletor Re: Hash Tables - 03/11/08 10:37 PM
Cheers mate, I will test it in a few.

Thanks for the reply.

Posted By: DJ_Sol Re: Hash Tables - 03/11/08 11:10 PM
I dont see your /hsave code. With yoru /hsave command choose the path you want.

you want to save it in mirc\file.hsh

or save it in mirc\hash\file.hsh ...

It's up to you.

/hsave table_name dir\subdir\subdir\file.hsh

I personally like to save as a .txt so I can open them and read them easier. Cheers!

Oh! If you want it to create the directory, use $Isdir to check if it's already made and then /mkdir <path> to create the directory.
© mIRC Discussion Forums