remini [Concept #1]

By alch3my on Mar 19, 2009

This alias replicates the /remini command using $ini and /write

Basically, we know that remini and writeini have constraints of doing what they're suppose to do in files larger than 64kb. From reading the mIRC Help File, this doesn't seem to affect $readini or $ini - from what I can tell anyway, as I didn't see any references.

I coded this as a Bot I created had to remove ini sections from a file much larger than 64kb, and was encountering issues while attempting to do so.

This snippet works exactly the same as remini, except it utilizes other mIRC commands to perform the function.

Usage: /_remini [item]

alias _remini {
  ;No file? Don't continue
  if (!$exists($1)) { return }
  ;Is the <inifile> larger than 64kb?
  if ($file($1).size > 65536) {
    ;Does the <section> exist?
    var %x = $iif($read($1,w,$+(*,$chr(91),$2,$chr(93),*)),$readn)
    if (%x) {
      ;How many items are located within the <section>?
      var %a = $ini($1,$2), %b = $ini($1,$ini($1,$ini($1,$2)),0)
      while (%b) {
        ;<section> found on line %x, delete %b items found within <section>
        if (!$3) { var %c = $calc(%b + %x) | write $+(-dl,%c) $1 }
        ;We're locating a specific [item] here within the <section>
        else {
          if ($ini($1,$ini($1,$ini($1,$2)),%b) == $3) { var %d = $calc(%x + %b) }
        }
        ;Keep searching <section>
        dec %b
      }
      ;[items] deleted from <section>, let's delete the header
      if (!$3) { write $+(-dl,%x) $1 }
      else {
        ;<section> found on line %x, however [item] wasn't located
        if (!%d) { return }
        ;<section> found on line %x, and [item] on line %d. Delete [item]
        else { write $+(-dl,%d) $1 }
      }
    }
  }
  ;File size isn't larger than 64kb, so we invoke standard command
  else { remini $1- }
}

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.