$_read Hybrid

By Arigateaux on Feb 25, 2014

This is a hybrid between $readini(), $read(), and $play(); whereas you can use the same file structure as an INI file without having to define items with variables. It was something that I was working on to use for something I'm working on myself, allowing for easier use.

[nicks]
evilMonkey
Foobar
Hawkee

;// $_read(file, section, item/N)
;// $_read(file.txt, nicks, Hawkee) ->  3
;// $_read(file.txt, nicks, 0)      ->  3
;// $_read(file.txt, nicks, 1)      ->  evilMonkey
alias _read {
  if ($isid) {
    var %i = 1
    var %n = $lines($1)
    while (%i <= %n) {
      if ($read($1, n, %i) == $+([,$2,])) {
        var %l = 1
        while (1) {
          inc %i
          var %a = $read($1, n, %i)
          if ($3 == %a) return %l
          if ($3 == 0) && (%i == %n) return %l
          if ($3 == 0) && ($regex(%a, /^\[.+\]$/)) return $calc(%l - 1)
          if ($3 == %l) && (!$regex(%a, /^\[.+\]$/)) return %a
          elseif (!$regex(%a, /\[.+\]/)) {
            inc %l
            continue
          }
          else return
        }
      }
      inc %i
    }
  }
}

Comments

Sign in to comment.
Arigateaux   -  Apr 06, 2014

If anyone has use for this, post a snippet of its use. :D

 Respond  
ProIcons   -  Apr 05, 2014

Nicely done, Liked

Arigateaux  -  Apr 06, 2014

Thanks. :)

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.