mIRC Home    About    Download    Register    News    Help

Print Thread
Hash Tables #205943 03/11/08 08:58 PM
Joined: Feb 2005
Posts: 185
S
Skeletor Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Feb 2005
Posts: 185
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.

Code:
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.

Cheers.
Matt


sub-zero.homeip.net:6667

Re: Hash Tables [Re: Skeletor] #205945 03/11/08 09:48 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Quick suggestion (untested)
I don't know what the -o switch should be for, though.
Code:
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

Last edited by Horstl; 03/11/08 09:54 PM.
Re: Hash Tables [Re: Horstl] #205947 03/11/08 10:37 PM
Joined: Feb 2005
Posts: 185
S
Skeletor Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Feb 2005
Posts: 185
Cheers mate, I will test it in a few.

Thanks for the reply.


Matt.


sub-zero.homeip.net:6667

Re: Hash Tables [Re: Skeletor] #205948 03/11/08 11:10 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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.