; Ini <-> hash table - Kyousoukyoku/XteNsion
; Syntax:
; /hash2ini (hash table) (ini name without the .ini) (ini topic to put items in)
; /ini2hash (ini without the .ini) (hashtable) (ini topic to put into hash table)
/*
Documentation;
Snippet title;Hash <-> INI
Author;Kyou./XN.
Date released;10/17/07
Updated;10/17/07
***************************
This snippet converts hash tables into ini files or vice versa. Pretty useful for switching different types of files. The syntax is: /hash2ini <hash> <ini> <topic> or /ini2hash <ini> <hash> <topic>. <topic> for /hash2ini simply puts the data from the hash table into the topic of the ini file. <topic> for /ini2hash transfers all items from the topic to the new hash table.
Any redistribution of any scripts made by this author without consent and credit to & for the author is forbidden. Please don't make a fool of yourself by overlooking this. Thanks - XN/Kyousoukyoku.
*/
alias hash2ini {
if ($3) {
if ($hget($1) && !$exists($+($2,.,ini))) {
var %x = 1
while ($hget($1,%x).item) {
writeini -n $+($2,.,ini) $3 $v1 $hget($1,%x).data
inc %x
}
echo $color(info) -a Now opening new ini file...
.timer 1 2 run $+($2,.,ini)
}
}
}
alias ini2hash {
if ($3) {
if ($exists($+($1,.,ini))) {
if (!$hget($2)) { hmake $2 }
var %x = 1
while ($ini($+($1,.,ini),$3,%x)) {
hadd $2 $v1 $readini($+($1,.,ini),$3,%x)
inc %x
}
echo $color(info) -a Now displaying new hash table...
.timer 1 2 /hashview $2
}
}
}
alias -l hashview {
if ($1) {
var %x = 1
if ($window(hashview)) { clear @hashview }
else { window -lk @hashview }
while ($hget($1,%x).item) {
aline -p @hashview $v1
inc %x
}
}
}