PHP Commands - /require 1.0

By XTZGZoReX on Jan 19, 2008

This is my first piece of code to add PHP-like commands to mIRC. I don't know if anyone have done this before, but I'm writing these from scratch.

Command: /require
Version: 1.0
Author: XTZGZoReX

Purpose: To require a file and continue, or halt if file was not found.
Usage: /require filename.mrc
Notes: It parses everything in the included file as commands, so please don't have anything else in the file. Also, it doesn't have any error handlers as of now, and doesn't support INI files.

Enjoy!

alias require {
  if ( $exists($1) != $true ) {
    echo -a * /require: error loading $1 $+ , halting script...
    halt
  }
  elseif ( $exists($1) == $true ) {
    if ( $right($1,4) != .ini ) {
      var %lines = 1
      while ( %lines <= $lines($1) ) {
        $read($1,%lines) $+ $crlf
        inc %lines
      }
    }
    else {
      halt
    }
  }
}

Comments

Sign in to comment.
Spartacus   -  Jan 19, 2008

Just a small note, The file either exists or it doesn\'t. Therefore, \"if ($exists($1)) { } | else { }\" would suffice. Also, \"else { halt }\" is essentially useless since it will never be triggered seeing as the file either exists or does not ;o Hope this helps you improve your code a little bit.

 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.