
###### <Kamek!20204> ok, here's all about cactive:
on *:ACTIVE:*:if ($lactivecid != $cid) && ($lactivecid) { airc_callhook cactive }
I don't know where it would be located
maybe it should be on the core (as an "extension" to mIRC events).
of course, if it's part of the core, don't use stdlib functions, like _*varg.
I put this here because this is an easy way to talk to you guys.
for now, I'm using kamek_cactive (oh, and that var can be replaced with something else too.)



;;;;;;;
;;;;;;; Variables functions
;;;;;;;

--------------------------------------------------------------------------------
_setvar
  Sets a "variable" for the current IRC session

  Syntax: /_setvar <variable> [data]

  Parameters
    variable
      The name of the variable, the "%" prefix is NOT needed since this is not
      a mIRC variable.
      The $chr(1) character is reserved and can't be used in the variable name.
    data
      The value that will be assigned to the variable.

  Return values
    This function returns nothing.

  Remarks
    If data is $null, then the variable will be removed.

  Requirements
    stdlib.amd 20112

  See Also
    _setfvar

--------------------------------------------------------------------------------
_setfvar/_incvar/_decvar
  Sets a "variable" for the current IRC session, just as _setvar, but 
  this function allows you to use the switches of the /hadd command.

  Syntax: /_setvar [-switches] <variable> [data]

  Parameters
    -switches
      Switches for the /hadd command, read mirc.hlp for more info
    variable
      The name of the variable, the "%" prefix is NOT needed since this is not
      a mIRC variable.
      The $chr(1) character is reserved and can't be used in the variable name.
    data
      The value that will be assigned to the variable.

  Return values
    This function returns nothing.

  Remarks
    If data is $null, then the variable will be removed.
    The "-switches" parameter is specially useful for the "-uN" switch, so this
    function can be used to write flood protection routines and features like
    that.
    The _incvar and _decvar functions use the same switches as _setfvar

  Requirements
    stdlib.amd 20112

  See Also
    _setvar

--------------------------------------------------------------------------------
_unsetvar
  Unsets a variable or all the variables that match a wildcard.

  Syntax: /_unsetvar <variable|wildcard> [variable|wildcard] ...

  Parameters
    variable
      Unsets the variable
    wildcard
      Unsets all the variables matching the wildcard

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_getvar
  Returns the value of a variable.
  Can be multiple lines.

  Syntax: $_getvar(<variable>)

  Parameters
    variable
      The name of the variable, the "%" prefix is NOT needed since this is not
      a mIRC variable.

  Return values
    Returns the data stored in the variable, or $null if the variable was empty

  Requirements
    stdlib.amd 20112

  See Also
    ...

;;;;;;;
;;;;;;; Settings functions
;;;;;;;

--------------------------------------------------------------------------------
_hmake
  Creates a hash table

  Syntax: /_hmake <hname> [slots]

  Parameters
    hname
      The name of the hash table
    slots
      The slots for the hash table, is this parameter is not specified, the
      table will use a default slot size of "10"

  Return values
    This function returns nothing.

  Remarks
    If the table already exists, this function will free the table and will
    create it again, so be careful.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_hmakeifempty
  Creates a hash table ONLY if the table doesn't already exist

  Syntax: /_hmakeifempty <hname> [slots]

  Parameters
    hname
      The name of the hash table
    slots
      The slots for the hash table, is this parameter is not specified, the
      table will use a default slot size of "10"

  Return values
    This function returns nothing.

  Remarks
    This fucntion will create the table ONLY if the table doesn't exist. If
    the table exists nothing will happen.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_hfreeifempty
  Frees a hash table if the table is empty.

  Syntax: /_hfreeifempty <table>

  Parameters
    table
      The hash table to free

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_hadd
  Adds an item to an existing hash table. If the item is empty, it will be
  removed from the table.

  Syntax: /_hadd <name> <item> [data]

  Parameters
    name
      The hash table
    item
      The item in the table
    data
      The data for the item in the table, can be $null

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_sets
  Stores a setting in a hash table using the simple "item" method.

  Syntax: /_sets <table> <item> [data]

  Parameters
    table
      The name of the table, it wil be prefixed internally with "stdlib_"
    item
      The name of the item in the table
    data
      The data that will be stored, if it is $null, the item will be removed
      from the table

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_setd
  Stores a setting in a hash table using the double "section item" method.

  Syntax: /_setd <table> <section> <item> [data]

  Parameters
    table
      The name of the table, it wil be prefixed internally with "stdlib_"
    section
      The name of the section in the table
    item
      The name of the item in the section
    data
      The data that will be stored, if it is $null, the item will be removed
      from the table

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_get
  Retrieves a setting from a table

  Syntax: $_get(<table>,<item>) for /_sets settings
          $_get(<table>,<section>,<item>) for /_setd settings

  Parameters
    table
      The name of the table, it wil be prefixed internally with "stdlib_"
    section
      Use this if you are calling a setting stored with /_setd
    item
      The item you want to retrieve

  Return values
    Returns the content of the setting or $null if the setting didn't exist

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_delhsection
  Removes a /_setd section of a hash table

  Syntax: /_delhsection <table> <section>

  Parameters
    table
      The name of the table, it wil be prefixed internally with "stdlib_"
    section
      The name of the section in the table that will be removed

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_setsetup
  Stores a setting in the main hash table (stdlib_setup) and saves it to
  "script.dat"

  Syntax: /_setsetup <section> <item> [data]

  Parameters
    section
      The name of the section in the table
    item
      The name of the item in the section
    data
      The data that will be stored, if it is $null, the item will be removed
      from the table

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_settsetup
  Stores a setting in the main hash table (stdlib_setup) and queues a save to
  "script.dat" in 15ms, so you can use this function to store a lot of data in
  a short period of time without freezing mIRC

  Syntax: /_settsetup <section> <item> [data]

  Parameters
    section
      The name of the section in the table
    item
      The name of the item in the section
    data
      The data that will be stored, if it is $null, the item will be removed
      from the table

  Return values
    This function returns nothing.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_getsetup
  Retrieves a setting stored with /_setsetup

  Syntax: $_getsetup(<section>,<item>)

  Parameters
    section
      The name of the section
    item
      The item you want to retrieve

  Return values
    Returns the content of the setting or $null if the setting didn't exist

  Requirements
    stdlib.amd 20112

;;;;;;;
;;;;;;; File functions
;;;;;;;

--------------------------------------------------------------------------------
_dccignore
  Checks if a given file will be ignored on a dcc send.

  Syntax: $_dccignore(<filename>)

  Parameters
    filename
      The filename to check.

  Return values
    Returns "1" if the file will be ignored, "0" if it won't.

  Remarks
    Note that if DCC Ignore is disabled, this function will always return "0",
    even if the file is in mIRC's ignored list.

  Example Code
    $_dccignore(pamsuck.jpg.exe)


  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_fixfilename
  Fixes a filename.
  It can also convert full paths to relative paths and viceversa.

  Syntax: $_fixfilename(<filename>,[flags])

  Parameters
    filename
      The filename to process
    flags
      f - If filename has invalid characters, replace them with "_"
      n - Don't bother for invalid filenames
      e - If file doesn't exist, returns $null
      m - If file is in $mircdir, removes $mircdir (relative path)

  Return values
    Returns a "correct" filename, depending on the options given, can return a
    full path or a relative path.
    If the "e" flag is used and the file doesn't exist or if the "n" flag is
    not used and the filename has invalid characters, the function will return
    $null

  Example Code
    $_fixfilename(c:\somedir\somefile.txt,+e)

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_fixdir
  Fixes a directory.
  It can also convert full paths to relative paths and viceversa.

  Syntax: $_fixdir(<directory>,[flags])

  Parameters
    directory
      The directory to process
    flags
      e - If dir doesn't exist, returns $null
      m - If dir is in $mircdir, removes $mircdir

  Return values
    Returns a "correct" directory, depending on the options given, can return a
    full path or a relative path.
    If the "e" flag is used and the directory doesn't exist the function will
    return $null

  Example Code
    $_fixdir(c:\somedir\anotherdir\,+e)

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_randfile
  Generates a random filename.

  Syntax: $_randfile([extension])

  Parameters
    extension
      The extension the filename will have, if no extension is given, it will
      be ".tmp"

  Return values
    Returns a temporary filename, no paths, only the filename.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_logfile
  Returns the logfile associated to a given window.

  Syntax: $_logfile(<window>)

  Parameters
    window
      The window given.

  Return values
    Returns the log file associated to the window, or $null if the window is
    invalid.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_logdir
  Returns the path to the logdir or to a file in the logdir

  Syntax: $_logdir([file])

  Parameters
    file
      An optional file.

  Return values
    Returns the path to the logdir. If a file is given, the function returns
    the path to the file in the logdir.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_isdir
  Same as $isdir() but this one returns the dir given or $null instead of
  $true/$false

  Syntax: $_isdir(<directory>)

  Parameters
    directory
      The directory to check

  Return values
    If the directory exists, the function will return it, else it will return
    $null.

  Remarks
    This function should be used for $ifmatch

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_isfile
  Same as $isfile() but this one returns the filename given or $null instead of
  $true/$false

  Syntax: $_isfile(<filename>)

  Parameters
    filename
      The filename to check

  Return values
    If the file exists, the function will return it, else it will return $null.

  Remarks
    This function should be used for $ifmatch

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_isdisk
  Checks if a given drive is a valid drive

  Syntax: $_isdisk(<driveletter>)

  Parameters
    driveletter
      The drive to check.

  Return values
    If the drive exists, the function will return it's letter, else it will
    return $null.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_mini
  A function to retrieve settings from mIRC's mirc.ini ($mircini)

  Syntax: $_mini(<section>,<item>)

  Parameters
    section
      The [section] in the file
    item
      The item= in the file

  Return values
    The item requested or $null if the item didn't exist.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_minio
  A function to retrieve settings from the [options] section in mIRC's
  mirc.ini ($mircini)
  For example:
    [options]
    n0=0,0,0,0,0,0,300,0,0,0,1,0,0,0,0,0,1,0,0,0,4096,0,1,4,0,0,1,1,0,50,0,0

  Syntax: $_minio(<#>,<token>)

  Parameters
    #
      The n# line in the [options] section
    token
      the nth option in the list

  Return values
    The value requested or $null if the item didn't exist.

  Example Code
    $_minio(0,5) - for the 5th item in the n0= line

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_size
  Transform a number of bytes in a descriptive string like "1.18 MB"
  The unit depends on the number of bytes given.

  Syntax: $_size(<bytes>)

  Parameters
    bytes
      Must be a number.

  Return values
    Returns a descriptive size depending on the number of bytes.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_psize
  Transform a number of bytes in a equivalent size in MBs like "1.18"
  The function will always return two decimals (X.XX)

  Syntax: $_psize(<bytes>)

  Parameters
    bytes
      Must be a number.

  Return values
    A MB equivalent of the value given in a X.XX format

  Remarks
    If the value is <= 5242, the function will return 0.00

  Requirements
    stdlib.amd 20112

;;;;;;;
;;;;;;; Boolean operators
;;;;;;;

--------------------------------------------------------------------------------
_s2b
  String to boolean.

  Syntax: $_s2b(<string>)

  Parameters
    string
      The string to process

  Return values
    If "string" is $false, 0 or $null, the function will return 0, else it will
    return 1

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_not
  Boolean NOT

  Syntax: $_not(<string>)

  Parameters
    string
      The string to process

  Return values
    If "string" is $false, 0 or $null, the function will return 1, else it will
    return 0

  Requirements
    stdlib.amd 20112

;;;;;;;
;;;;;;; Text/Strings Identifiers
;;;;;;;

--------------------------------------------------------------------------------
_text2html
  Replaces all the "weird" characters from a string with their &code; HTML
  equivalents.

  Syntax: $_text2html(<string>)

  Parameters
    string
      The string to HTMLize

  Return values
    Returns the string with all the weird-not-html-replaced with their &code;
    equivalents.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_saferegex
  Converts the regex special characters to their \char equivalent

  Syntax: $_saferegex(<string>)

  Parameters
    string
      The string to convert

  Return values
    Returns the string with all the regex special characters converted to their
    \char equivalents

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_defrgbs
  Returns a comma separated string of the default rgb values for all the mIRC
  colors (0-15)

  Syntax: $_defrgbs

  Parameters
    This function has no parameters.

  Return values
    A comma separated string of the default rgb values for all the mIRC colors
    (0-15)

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_wordisinstring
  Verifies if a word is present in a string of text. It will ignore characters
  as commas, parenthesis, etc. Note that it will check that the FULL word is in
  the string, it's not a simple "word isin string"

  Syntax: $_wordisinstring(<word>,<string>)

  Parameters
    word
      The word that we want to check
    string
      The string of text

  Return values
    Returns "1" if the word is in the string, else it returns "0".

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_randstring
  Generates a string of random characters

  Syntax: $_randstring(<length>,<flags>)

  Parameters
    length
      The length of the string.
    flags
      What kind of characters to use. Can use more than one flag at the same
      time.
        n - numbers
        l - lowercase letters
        u - uppercase letters
        c - other ascii characters

  Return values
    Returns a string of random characters.

  Remarks
    If no flags are given, the function will use the +nlu flags by default.
    The max length supported is $_maxstrlen characters.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_randtok
  Returns a random token.

  Syntax: $_randtok(<text>,<C>)

  Parameters
    text
      A string of text
    C
      The ascii value of the character separating the tokens

  Return values
    Returns a random token from <text>

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_fixmodes
  This function "fixes" user-given modes (+bb-oov) to more easier-to-parse
  modes (+b+b-o-o-v)

  Syntax: $_fixmodes(<modes>)

  Parameters
    modes
      The modes to "fix"

  Return values
    Returns a "fixed" string of modes.
    Will return $null if there were no valid modes

  Remarks
    This function WILL NOT check for "valid modes", it will only check for "-"
    and "+" characters, all the other characters wil be taken as valid modes.
    This function will NOT check for duplicated modes.

  Requirements
    stdlib.amd 20112

  See Also
    _unfixmodes

--------------------------------------------------------------------------------
_unfixmodes
  This function will convert easy-to-parse-modes (+o+o-b-b) to
  user-given-like-modes (+oo-bb)

  Syntax: $_unfixmodes(<modes>)

  Parameters
    modes
      The modes to "unfix"

  Return values
    Returns an "unfixed" string of modes.
    Will return $null if there were no valid modes

  Remarks
    This function WILL NOT check for "valid modes", it will only check for "-"
    and "+" characters, all the other characters wil be taken as valid modes.
    This function will NOT check for duplicated modes.

  Requirements
    stdlib.amd 20112

  See Also
    _fixmodes

--------------------------------------------------------------------------------
_changemodes
  Performs a "modechange" (+ikl-s) to a modes string (+nst)

  Syntax: $_changemodes(<origmodes>,<+-modes>)

  Parameters
    origmodes
      The original modes string
    +-modes
      The "modechange" string

  Return values
    Returns the old modes string after the mode change.

  Remarks
    This function assumes that a mode can't be more than one time in a modes
    string, so, if there is a "-k" in the modechange string, and a "+kk" in the
    original modes string, both "k" modes will be removed. But, if there is no
    "-k" in the modechange string, both "+kk" will be returned. This function
    will NOT check for duplicated modes in the original modes string for speed
    porpuses.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_reqchangemodes
  This function takes two parameters, the original modes and the desired modes,
  and will return the modechange that must be applied to the original modes to
  have the desired modes.

  Syntax: $_reqchangemodes(<originalmodes>,<newmodes>)

  Parameters
    originalmodes
      The old/original modes
    newmodes
      The new/desired modes

  Return values
    Returns the modechange needed to have the desired modes.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_isactivegroup
  A function to check if a mIRC group is enabled

  Syntax: $_isactivegroup(<#group>)

  Parameters
    #group
      The mIRC #group to check

  Return values
    Returns "1" if the group is enabled, "0" if it's disabled

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_nospaces
  Strips all spaces (ASCII 32) from a string of text.

  Syntax: $_nospaces(<string>)

  Parameters
    string
      A string of text.

  Return values
    Returns the original string without spaces, can be $null

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_filleft
  Aligns text to the right filling the left with as specified character.

  Syntax: $_filleft(<length>,<char>,<text>)

  Parameters
    length
      The length of the final string
    char
      the character that will be used to "fill" the empty space, can use
      control codes
    text
      The text that will be aligned

  Return values
    Returns the text aligned to the right.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_filright
  Aligns text to the left filling the right with as specified character.

  Syntax: $_filright(<length>,<char>,<text>)

  Parameters
    length
      The length of the final string
    char
      the character that will be used to "fill" the empty space, can use
      control codes
    text
      The text that will be aligned

  Return values
    Returns the text aligned to the left.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_ralign
  Aligns text to the right

  Syntax: $_ralign(<length>,<text>)

  Parameters
    length
      The length of the final string
    text
      The text that will be aligned

  Return values
    Returns the text aligned to the right.

  Remarks
    This function should be used only in windows, not in dialogs, because the
    empty space is filled with control codes, since mIRC doesn't have support
    for multiple spaces (ASCII 32) together.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_lalign
  Aligns text to the left

  Syntax: $_lalign(<length>,<text>)

  Parameters
    length
      The length of the final string
    text
      The text that will be aligned

  Return values
    Returns the text aligned to the left.

  Remarks
    This function should be used only in windows, not in dialogs, because the
    empty space is filled with control codes, since mIRC doesn't have support
    for multiple spaces (ASCII 32) together.

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_ischan
  Verifies if the string given is a valid channel name

  Syntax: $_ischan(<channel>)

  Parameters
    channel
      The channel to verify

  Return values
    Returns "1" if the string given is a valid channel, else it returns "0"

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_ismail
  Verifies if the string given is a valid email

  Syntax: $_ismail(<email>)

  Parameters
    email
      The email to verify

  Return values
    Returns "1" if the string given is a valid email, else it returns "0"

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_isip
  Verifies if the string given is a valid I.P.

  Syntax: $_isip(<IP>)

  Parameters
    IP
      The IP to verify

  Return values
    Returns "1" if the string given is a valid IP, else it returns "0"

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_isvalidfilename
  Verifies if the string given is a valid filename

  Syntax: $_isvalidfilename(<filename>)

  Parameters
    filename
      The filename to verify, filename only, no path

  Return values
    Returns "1" if the string given is a valid filename, else it returns "0".

  Requirements
    stdlib.amd 20112

--------------------------------------------------------------------------------
_ischanmode
  Checks if a mode is set in a channel.

  Syntax: $_ischanmode(<channel>,<mode>)

  Parameters
    channel
      The channel
    mode
      The mode, just the mode character without the "+"

  Return values
    Returns "1" if mode is set in the channel, else it returns "0"

  Requirements
    stdlib.amd 20112

