Mini-hash table editor

By Kyousoukyoku on Oct 18, 2007

Documentation lies within the code.

/*
Documentation;
Snippet;Mini-hash table editor
Author;Kyou./XN.
Release;10;18;07
********************************
Mini-hash editor. Edit data, add items, and delete items. Opens the hash table in a new window and lists the items accordingly. Decided to not use diaogs because everyone else does. ;) Syntax: /hasheditor (hash name). Easy to use. Ripping if forbidden, thanks.
*/

;;;;;;;;; ALIASES ;;;;;;;;;

alias hasheditor { 
  if ($1 && $hget($1)) { 
    if ($window(hasheditor)) { clear @hasheditor } 
    else { window -lk @hasheditor }
    var %x = 1
    set %hash $1
    while ($hget($1,%x).item) { 
      aline -p @hasheditor $v1 - $hget($1,%x).data
      inc %x
    }
  }
}

alias -l hashadd { 
  if ($hget($1)) {
    var %1 = $$?="Enter hash item:"
    var %2 = $$?="Enter hash data:"
    if (%1 && %2) {
      hadd %hash %1 %2 
      aline -p @hasheditor %1 - %2
      unset %1
    }
  }
}

alias -l hashdel {
  if ($hget($1)) { 
    var %1 = $sline($active, 1)
    var %2 = $sline($active, 1).ln
    hdel %hash $gettok(%1,1,32)
    dline @hasheditor %2
  }
}

alias -l hashedit { 
  if ($hget($1)) {  
    var %1 = $sline($active, 1).ln
    var %2 = $$?="Enter new item data"
    set %hashtmpsel $gettok($sline($active, 1),1,32)
    if (%2) { 
      hdel %hash %hashtmpsel
      hadd %hash %hashtmpsel %2
    }
    dline @hasheditor %1
    aline -p @hasheditor %hashtmpsel - %2
  }
}

menu @hasheditor { 
  add:hashadd %hash
  del:hashdel %hash
  edit:hashedit %hash
}

Comments

Sign in to comment.
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.