
  Extra Math - Version 5.1
  Written by Paranor
  http://scripts.paranor.dynip.com/
  paranor@paranor.dynip.com

  -----------------------------------------------------------------------------

  * NOTE: For updates to this script, please read the bottom of the file.

          If you wish to use any of the functions in this script for your own
          script(s), I ask that you make mention of my name and place my web
          address somewhere either in the script or any accompanying document
          file.  You may copy portions of this script to do this.  Thank you.



  To use xtramath.ini, simply load the file into your remote section.

  Do this by typing: /load -rs xtramath.ini

  or, open your remotes (ALT-R), select the FILE menu, then LOAD, then SCRIPT,
  and locate and select the xtramath.ini file.

  -----------------------------------------------------------------------------

  Xtra Math is a math and variable enhancement to mIRC that gives you some
  enhanced mathematical functions and identifiers not built into mIRC 5.7 and
  later.

  Xtra Math will create a directory inside your main mIRC directory called
  xmath\ which will be used for the data storage of all arrays.

  * NOTE: all items inside [ ] are optional parameters


  Array Functions:
  ----------------

  1st, an explination...

  An array is a special form of variable which uses the same name, but has many
  'blocks' where it can store data into.  Think of an array as a large box.
  Then, depending on how many blocks you want, you divide the box into smaller
  sections, making X number of blocks wide, and perhaps Y blocks tall.


  /dim [-o] NAME(x[,y])

  This prepares an array for use by defining the rows (x) and/or columns (y).
  An array MUST be defined before you can use it at all, and the name of the
  array must be an alphanumeric (letters and/or numbers) name.
  You can create a single array by just providing a value for X, or you can
  create a dual array by also providing a value for Y.
  You cannot resize an array after the array has been defined.  You must UNSET
  the array before you can redefine it's size.
  To unset an array, use the UNSET command in place of X and Y.
  If you use the -o option, then it will UNSET an array of the same name before
  defining the new size without the need of the UNSET parameter.

  Examples:

           /dim scores(10)
           /dim games(5,21)
           /dim -o games(21)
           /dim scores unset

  * Arrays are limited to a to a range of 1-99 by 1-99 blocks.
  * In the 16-bit mIRC, array names can only be upto 7 characters in size. If
    you use a name longer than 7 characters, then you can run into problems if
    you define multiple arrays with similar names.  In the 32-bit mIRC, you can
    define an array name upto 63 characters in length.


  /aset name(x[,y])

  This works just like mIRC's /set command for storing data in a variable, but
  this is used only for arrays.  Depending on the size you set with /dim, you
  store with x and/or y parameters.

  Examples:

           /aset nicks(1,4) Paranor
           /aset score(2) 232


  $array(name[,x[,y]])

  Properties: .size .x .y

  This will return the value stored at location X,Y in the array.
  You can use the .size property to return the full size that the array was
  dimensioned to.
  Using the .x property will return the maximum number of rows.
  Using the .y property will return the maximum number of columns.


  $sarray(name,wildstring[,matchnum|@window,C,N,P])

  This is used to search an array for the matching wildstring entered.
  If you specify a matchnum, then it will return the array value of the Nth
  match found, otherwise it will return the 1st match.  If matchnum is 0, then
  it will return the total number of matches found in the array.
  If you enter in a custom window name instead of matchnum, then all matching
  array values will be shown in the custom window given.
  If you specify C, then only that column (y) will be searched, if the array is
  a dual sized array.  If it is not a dual sized array, then you can specify C
  as 0 to allow the other parameters.
  If you specify a custom window and N is 1, all matching lines will be put
  into the side listbox of the @window.
  If P is 1, then the X/Y position will be shown in front of the matching array
  value found (works the same as the -n option in mIRC's /filter command).


  /ainc NAME(x[,y]) N

  This is just like mIRC's /inc command for variables, but is used for arrays.
  If the array block is $null when an /ainc is performed, then the array block
  will be set to a value of 1.
  If N is not given, then a value of 1 is assumed.


  /adec NAME(x[,y]) N

  This is just like mIRC's /dec command for variables, but is used for arrays.
  If N is not given, then a value of 1 is assumed.



  Math Functions:
  ---------------

  $trun(N,[R])

  This will return the decimal portion of number N.  You may also include the R
  parameter which will round up the decimal to R places (upto 10 places).

  Examples:

            $trun(4.2)   = 2
            $trun(100)   = 0
            $trun(1.4,2) = 40


  $mod(N,D)

  This will give you the remainder of N divided by D.

  Examples:

            $mod(10,3)  = 1
            $mod(10,2)  = 0
            $mod(40,12) = 4


  $hex(N[,C,Z])

  Convert decimal number N, to it's hexidecimal form or visa versa.
  If C is not given or C is 0, then a decimal to hex convertion is done.
  If C is 1, N must be a hexidecimal number to convert to decimal.
  Z is 1, then the 'zeropad' option is used to make the number a defined size,
  adding 0's to the front to ensure the returned number is Z numers long.

  Examples:

           $hex(10)     = A
           $hex(3F,1)   = 63
           $hex(3F,1,3) = 063


  $bin(N[,C,Z])

  Convert decimal number N, to it's binary form or visa versa.
  If C is not given or C is 0, then a decimal to binary conversion is done.
  If C is 1, N must be a binary number to convert to decimal.
  Z is 1, then the 'zeropad' option is used to make the number a defined size,
  adding 0's to the front to ensure the returned number is Z numers long.

  Examples:

           $bin(9)       = 1001
           $bin(110,1)   = 6
           $bin(110,1,2) = 06
           $bin(4,0,4)   = 0100


  * NOTE: With mIRC 5.7, there is the $base identifier which will convert
          decimal to hex or binary, and visa versa.  I have decided to keep the
          $hex and $bin identifiers to provide a convienent and 'English' use
          of these functions.


  $bitshift(N,S,D[,C])

  This is a binary function allowing you to shift the bits of the decimal or
  binary number N to the left or right.
  S is the number of bits that you want to shift from 1 to 7 places.
  D is the direction you want to shift the bits.  If D is 0, then the bits are
  shifted to the right.  If D is 1, then the bits are shifted left.
  If C is 1, it denotes that N is a binary number.

  * NOTE: N can only be a value between 0 and 255 in either decimal or binary.



  Other Custom Identifiers:
  -------------------------

  $uptime

  This will tell you in seconds how long you last started or rebooted your
  computer.


  $uptime(N[,format])

  This allows you to change the data returned by $uptime.
  If N is 0, the number of seconds since last restart will be returned.  If N
  is 1, then the CTime of when the computer was last restarted will be given.
  If N is 2, then the CTime in GMT will be returned.
  You can change the way the time is returned using the same format parameters
  as mIRC's $asctime identifier when N is 1 or N is 2, but not when N is 0.

  If N is 0:

    Week        w         1
                ww        01
                www       001
                wwww      0001

    Day         d         1
                dd        01
                ddd       01d
                dddd      01 days

    Hours       h         5
                hh        05
                H         13
                HH        13

    Minutes     n         1
                nn        01

    Seconds     s         1
                ss        01

    AM/PM       t         a/p
                tt        am/pm
                T         A/P
                TT        AM/PM

  * Note: If you don't specify N, then 0 is assumed.


  $month

  This will return the full name of the current month.


  $month(format)

  For every m you place for the format, you will get that length of the month's
  name using upto 4 m's.  If you enter in 0 as the format, then the total
  number of days in the current month will be returned.
  
  Examples:

           $month(mm)   = Ja
           $month(mmm)  = Jan
           $month(mmmm) = January
           $month(0)    = 31


  $rot13(string)

  This performs a 13 character rotation of all letters in the string you input,
  encoding it.  If the string contains characters other than letters, then they
  will be removed.  The unique feature of ROT13 is that if you rotate a string
  already processed with ROT13, it comes out uncoded.  This is because there
  are 26 characters in the English alphabet, and 13 is the middle of it.


  $replacean(string[,string])

  This replaces all characters in string that are not letters or numbers with
  STRING, or removed if no string given.  You can use the $replaced identifier
  to tell you how many characters were replaced or removed.

  -----------------------------------------------------------------------------

  Any bugs, comments, suggestions...feel free to e-mail me at the e-mail
  address at the top of this document.

  * NOTE: These identifiers are built for mIRC 5.7 and above.

  -----------------------------------------------------------------------------

  * What's New?
  =============

  v5.1 - Added $mod and $trun

  v5.0 - Revised all functions improving speed and flexability
       - Added $uptime identifier
       - Removed $and $or $xor identfiers (now built into mIRC 5.7)
       - Replaced $shiftr and $shiftl with $bitshift
       - Replaced $repan and $stripan with $replacean
       - Added $replaced ident to show number of characters replaced with
         $replacean
       - Modified $month to allow greater flexability

  v4.0 - Added $month identifier
       - Added array commands /ainc /adec
       - Rewrote handler for variables and identifiers inside array routines.
         It now fully resolves them before working the array

  v3.8 - Added $shiftr $shiftl bit operators
       - Added $repan function

  v3.6 - Fixed bug in array handler that would not allow use of variables or
         identifiers for parameters

  v3.5 - Added $stripan

  v3.3 - Added $rot13

  v3.2 - Added $sarray for searching an array

  v3.0 - Removed the $boolean function since mIRC 5.4 + now has the $iif
         function
       - Added array handlers: /dim name x(,y)|unset
                               /aset name(x(,y)) <data>
                               $array(name(,x(,y)))

  v2.0 - Added $boolean math function
       - 1st public release
