Ini <-> Hash table

By Kyousoukyoku on Oct 17, 2007

; 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 can be found in the code.
/*
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
    }
  }
}

Comments

Sign in to comment.
Gummo   -  Oct 18, 2007

It will have increased your scripting ability nonetheless. :)

 Respond  
Kyousoukyoku   -  Oct 18, 2007

Hmm... never knew that before lol. ^^ Guess I just overcomplicated a built-in feature of mIRC then. ;)

 Respond  
xDaeMoN   -  Oct 17, 2007

You simply do this with /hload & /hsave using the switch \"-i\".

The -i switch treats the file as an ini file. You can specify an optional section name after the filename.

/hload -sbni [section]
/hsave -sbniau [section]
Load or save a table to/from a file.

;)

 Respond  
Kyousoukyoku   -  Oct 17, 2007

Code has been updated, thanks.

 Respond  
guest598594   -  Oct 17, 2007
  if ($1 && $2 && $3) { 

just do

if ($3) {

cuz if theres $3, theres automatically $1 and $2

 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.