Hash Saver

By Ghost-writer on Dec 21, 2009

This is my hash saver :), Just right click your background or type: /HashDialog Result, you get a dialog with the little unchecked buttons, Check them, and you never lose your hash tables again :D! You can also save immeditly or load immeditly via the button :).

menu channel,Status {
  Hash Saver: hashdialog
}
on *:exit: if ($hget(files, save) == on) hashsave
on *:start: {
  hload files files/files.txt
  if ($hget(Files, load) == on) hashload
}
alias hashsave {
  if (!$exists(Files)) mkdir Files
  if (!$hget(files)) hmake files 5
  var %x $hget(0)
  while (%x) {
    hsave $hget(%x) $+(Files/,$hget(%x),.txt)
    hadd Files $hget(%x) Hash Table
    dec %x
  }
  hsave files files.txt
}
alias hashload {
  if (!$hget(Files)) hmake files 5
  hload files files/files.txt
  var %x $hget(Files, 0).item
  while (%x) {
    if (!$regex($hget(files, %x).item,/load|sav|file/si)) {
      if (!$hget($hget(files, %X).item)) hmake $hget(files,%x).item
      hload $hget(Files,%x).item $+(Files/,$hget(Files, %x).item,.txt)
    }
    dec %x
  }
}
alias hashdialog dialog -mo hashsaver hashsaver
Dialog HashSaver {
  option dbu
  size -l -l 120 130
  title "Hash Saver - V1.0"
  check "Automatically Save Files On Exit", 1, 10 45 90 10, 
  check "Automatically Load Files On Start", 3, 10 55 90 10,
  check "Save files every 60 seconds.", 4, 10 65 90 10,  
  box "Options", 2, 5 35 100 45
  List 5, 1 85 115 45,vshbar
  button "Save Files" 6, 5 10 30 10
  button "Load Files" 7, 35 10 30 10
}
on *:dialog:Hashsaver:*:*: {
  if ($devent == init) {
    if ($hget(files, save) == on) did -c $dname 1
    if ($hget(files, load) == on) did -c $dname 3
    if ($timer(savefiles)) did -c $dname 4
    did -ra $dname 5 Hash Tables Saved.
    var %x $findfile($mircdir $+ \files,*.txt,0)
    while (%x) {
      if (!$regex($remove($findfile($mircdir $+ \files,*.txt,%x),$mircdir $+ \files\,.txt),/files|save|load/si)) {
        did -a $dname 5 $remove($findfile($mircdir $+ \files,*.txt,%x),$mircdir $+ \files\,.txt)
      }
      dec %x
    }
  }
  elseif ($devent == sclick) {
    if ($did == 1) {
      if ($did(1).state) hadd files Save on
      else hadd files save off
    }
    elseif ($did == 3) {
      if ($did(3).state) hadd files Load on
      else hadd files Load off
    }
    elseif ($did == 4) {
      if ($did(4).state) .timersavefiles 0 60 hashsave
      else .timersavefiles off
    }
    elseif ($did == 6) hashsave
    elseif ($did == 7) {
      hashload
      did -ra $dname 5 Hash Tables Saved.
      var %x $findfile($mircdir $+ \files,*.txt,0)
      while (%x) {
        if (!$regex($remove($findfile($mircdir $+ \files,*.txt,%x),$mircdir $+ \files\,.txt),/files|save|load/si)) {
          did -a $dname 5 $remove($findfile($mircdir $+ \files,*.txt,%x),$mircdir $+ \files\,.txt)
        }
        dec %x
      }
    }
  }
}
Sign in to comment.
DarkCoder   -  Dec 21, 2009

Good for storing hash tables :P, gets kinda slow if you have huge hash tables like me, buts its fine :).

 Respond  
Master-Of-Death   -  Dec 21, 2009

gd idea 6/10, nice use of dialogs and aliases 4/10 overall 5/10

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.