A simple code that allows you to view the items in a hash table. It gives you the option to delete or add items on free will.
/hview (hash) - lists all items in the table in the new window, giving you the option to remove or add the items
/hview - lists all hash tables, giving you the option to release them or make new ones. ;)
alias hview {
var %x 1
if ($1) {
if (!$window(hash)) { window -lk @hash }
elseif ($window(hash)) { clear @hash }
while ($hget($1,%x).item) {
aline -p @hash $v1
inc %x
}
set %hash $1
}
elseif (!$1) {
if (!$window(hash_all)) { window -lk @hash_all }
elseif ($window(hash_all)) { clear @hash_all }
while ($hget(%x)) {
aline -p @hash_all $v1
inc %x
}
}
}
menu @hash {
remove:{
if ($gettok($sline($active, 1),1-,32)) {
hdel %hash $v1
dline @hash_all $sline($active, 1).ln
}
}
add:{
var %hashtemp $?="Enter item name"
var %hashtemp1 $?="Enter item data"
if (%hashtemp && %hashtemp1) { hadd %hash %hashtemp %hashtemp1 }
aline -p @hash %hashtemp
}
}
menu @hash_all {
free:{
if ($gettok($sline($active, 1),1-,32)) {
hfree $v1
dline @hash_all $sline($active, 1).ln
}
}
new:{
var %hashtemp $?="Enter table name"
if (%hashtemp) {
var %hashtemp1 $?="Enter table storage amount"
if (%hashtemp1) {
hmake %hashtemp %hashtemp1
aline -p @hash_all %hashtemp
}
}
}
}