From WikiChip
Difference between revisions of "mirc"

m (Fix typo)
(Add overview of data storage.)
Line 8: Line 8:
 
mSL code can be executed right from text box or in the case of more complex scripts as {{mirc|aliases}} or as {{mirc|on events}}. {{mirc|Aliases}} are mSL's version of [[functions]] while {{mirc|on events}} are triggered events that automatically activate when the appropriate event occurs.
 
mSL code can be executed right from text box or in the case of more complex scripts as {{mirc|aliases}} or as {{mirc|on events}}. {{mirc|Aliases}} are mSL's version of [[functions]] while {{mirc|on events}} are triggered events that automatically activate when the appropriate event occurs.
  
=== Language Constructs ===
+
== Language Constructs ==
 
{{main|mirc/conditional_statements|mirc/while_loops|mirc/operators|l1=mSL If Statements|l2=mSL Looping Statements|l3=mSL Operators}}
 
{{main|mirc/conditional_statements|mirc/while_loops|mirc/operators|l1=mSL If Statements|l2=mSL Looping Statements|l3=mSL Operators}}
 
mSL inherits most of its syntax from the [[C Programming Language]] with respect to both the curly syntax as well as its general behavior. For example, like in C, constructs such as {{mirc|if statements}} evaluate to {{mirc|$true}} for anything other than <code>0</code> and <code>$false</code>. For example <code>if (1) { .. }</code>.
 
mSL inherits most of its syntax from the [[C Programming Language]] with respect to both the curly syntax as well as its general behavior. For example, like in C, constructs such as {{mirc|if statements}} evaluate to {{mirc|$true}} for anything other than <code>0</code> and <code>$false</code>. For example <code>if (1) { .. }</code>.
Line 14: Line 14:
 
A big departure from most other languages is the fact that mSL makes no distinction between code and plain text. Code is often embedded among plain text and is evaluated as such. For example <code>One $calc(1+1) Three</code> will correctly treat the <code>One</code> as plain text, {{mirc|evaluate}} the {{mirc|$calc}} {{mirc|identifier}} into <code>2</code> and finally treat <code>Three</code> as plain text. The result will be <code>One 2 Three</code>. On the surface this may seem like it could result in many ambiguities, however in practice it works fairly fluidly with just a handful of problematic cases - many of which can be easily escaped.  
 
A big departure from most other languages is the fact that mSL makes no distinction between code and plain text. Code is often embedded among plain text and is evaluated as such. For example <code>One $calc(1+1) Three</code> will correctly treat the <code>One</code> as plain text, {{mirc|evaluate}} the {{mirc|$calc}} {{mirc|identifier}} into <code>2</code> and finally treat <code>Three</code> as plain text. The result will be <code>One 2 Three</code>. On the surface this may seem like it could result in many ambiguities, however in practice it works fairly fluidly with just a handful of problematic cases - many of which can be easily escaped.  
  
=== Variables and text utilities ===
+
== Variables and text utilities ==
 
{{main|mirc/variables|mirc/string_manipulation|mirc/token_manipulation|l1=mSL Variables|l2=mSL String Manipulation|l3=mSL Token Manipulation}}
 
{{main|mirc/variables|mirc/string_manipulation|mirc/token_manipulation|l1=mSL Variables|l2=mSL String Manipulation|l3=mSL Token Manipulation}}
 
mSL offers a plethora of facilities that provide an extensive set of ways to work with text and manipulate it. {{mirc|Variables}} can be global, in which case they persist for ever until manually removed, or local - which are automatically after returning from an {{mirc|on events|event}} or an {{mirc|alias|alias call}}. Variables are defined using the {{mirc|/var}} command and have no fixed data type. In fact everything is more or less treated as plain text with the exception of a handful of {{mirc|identifiers}} that operate on numbers.
 
mSL offers a plethora of facilities that provide an extensive set of ways to work with text and manipulate it. {{mirc|Variables}} can be global, in which case they persist for ever until manually removed, or local - which are automatically after returning from an {{mirc|on events|event}} or an {{mirc|alias|alias call}}. Variables are defined using the {{mirc|/var}} command and have no fixed data type. In fact everything is more or less treated as plain text with the exception of a handful of {{mirc|identifiers}} that operate on numbers.
Line 24: Line 24:
 
In addition to be treated as plain text, values can also be treated as a list of tokens and operated on using the various {{mirc|token manipulation}} identifiers. For example, considering the <code>%variable</code> from above, one can treat spaces as a [[delimiter]] and thus use {{mirc|$gettok}} to obtain the 3rd token using <code>$gettok(%variable, 3)</code>.
 
In addition to be treated as plain text, values can also be treated as a list of tokens and operated on using the various {{mirc|token manipulation}} identifiers. For example, considering the <code>%variable</code> from above, one can treat spaces as a [[delimiter]] and thus use {{mirc|$gettok}} to obtain the 3rd token using <code>$gettok(%variable, 3)</code>.
  
=== Data Storage ===
+
== Data Storage ==
{{main|mirc/ini_files|mirc/hash_tables|mirc/text_files|l1=mSL INI Files|l2=mSL Hash Tables|l3=mSL Text Files}}
+
{{main|mirc/variables|mirc/ini_files|mirc/hash_tables|mirc/text_files|l1=mSL Variables|l2=mSL INI Files|l3=mSL Hash Tables|l4=Text Files}}
{{empty section}}
+
Being an [[event-driven]] [[scripting language]], mSL only (normally) executes scripts in response to either an IRC event (i.e. a message from the IRC server), an input event by the user, or a timer event. (Indeed, mIRC needs the time in between executing scripts for these events in order to do its own processing.) If you want to store information between these event-driven script executions, then you need to use one of the several data storage methods available in mIRC.
 +
 
 +
Your choice of method depends on three things:
 +
# Persistence of data after mIRC is closed
 +
# Volume of data - the performance impact and volume limitations of mIRC
 +
# The functionality you need to access and process the data
 +
 
 +
The most functional and highest performance storage method is {{mirc|hash tables}}, which are suitable for large volumes of data and for frequent read and write access. However whilst you can save and restore hash tables from files, you can only save the entire table which has a significant overhead and any changes made since the last save will be lost when mIRC terminates.
 +
 
 +
The simplest and easiest to use is {{mirc|variables}}, particularly suitable for simple low-volume data like script settings.
 +
 
 +
{{mirc|variables}}, {{mirc|ini files}} and {{mirc|text files}} all write data to flat files, and are suitable for moderate volumes of data and write activity.
 +
 
 +
For large volume persistent data, needing both high performance and file storage, you may need to store the data in both hash tables for read access and {{{mirc|ini files}} for write storage.
 +
 
 +
If you need advice before coding, why not ask for advice in one of the mIRC scripting channels on IRC.
  
 
== History ==
 
== History ==

Revision as of 14:09, 23 September 2017

mirc logo.png

The mIRC Scripting Language, abbreviated as mSL, is an event-driven, procedural scripting language embedded inside the mIRC client. mSL's main feature is its seamless ability to interact with other IRC clients on IRC in order to perform a variety of tasks.

Although widely used to make bots to automatically manage a channel, mIRC can also be modified, via the scripting language mSL, to include a host of new features, such as: basic games, small functions and macros, the ability to play music, and even operate small applications. Scripts are stored in plain text files (.mrc) or as INI files. With the aid of COM scripts and DLLs, mSL can be further extended to automate just about everything in the Windows environment.

Overview

Main article: Introduction to mSL

mSL code can be executed right from text box or in the case of more complex scripts as aliases or as on events. Aliases are mSL's version of functions while on events are triggered events that automatically activate when the appropriate event occurs.

Language Constructs

Main articles: mSL If Statements, mSL Looping Statements, and mSL Operators

mSL inherits most of its syntax from the C Programming Language with respect to both the curly syntax as well as its general behavior. For example, like in C, constructs such as if statements evaluate to $true for anything other than 0 and $false. For example if (1) { .. }.

A big departure from most other languages is the fact that mSL makes no distinction between code and plain text. Code is often embedded among plain text and is evaluated as such. For example One $calc(1+1) Three will correctly treat the One as plain text, evaluate the $calc identifier into 2 and finally treat Three as plain text. The result will be One 2 Three. On the surface this may seem like it could result in many ambiguities, however in practice it works fairly fluidly with just a handful of problematic cases - many of which can be easily escaped.

Variables and text utilities

Main articles: mSL Variables, mSL String Manipulation, and mSL Token Manipulation

mSL offers a plethora of facilities that provide an extensive set of ways to work with text and manipulate it. Variables can be global, in which case they persist for ever until manually removed, or local - which are automatically after returning from an event or an alias call. Variables are defined using the /var command and have no fixed data type. In fact everything is more or less treated as plain text with the exception of a handful of identifiers that operate on numbers.

var %variable this is some text, %2ndbar this is more text

There is a large number of identifiers that can operate on strings - anything from determining the size, to obtaining a portion of the string from the beginning or end, to case transformation, and pattern matching. For example, the simple $left identifier can be used to obtain a portion from the left side of the string - e.g., $left(Hello!!, 4) will yield Hell.

In addition to be treated as plain text, values can also be treated as a list of tokens and operated on using the various token manipulation identifiers. For example, considering the %variable from above, one can treat spaces as a delimiter and thus use $gettok to obtain the 3rd token using $gettok(%variable, 3).

Data Storage

Main articles: mSL Variables, mSL INI Files, mSL Hash Tables, and Text Files

Being an event-driven scripting language, mSL only (normally) executes scripts in response to either an IRC event (i.e. a message from the IRC server), an input event by the user, or a timer event. (Indeed, mIRC needs the time in between executing scripts for these events in order to do its own processing.) If you want to store information between these event-driven script executions, then you need to use one of the several data storage methods available in mIRC.

Your choice of method depends on three things:

  1. Persistence of data after mIRC is closed
  2. Volume of data - the performance impact and volume limitations of mIRC
  3. The functionality you need to access and process the data

The most functional and highest performance storage method is hash tables, which are suitable for large volumes of data and for frequent read and write access. However whilst you can save and restore hash tables from files, you can only save the entire table which has a significant overhead and any changes made since the last save will be lost when mIRC terminates.

The simplest and easiest to use is variables, particularly suitable for simple low-volume data like script settings.

variables, ini files and text files all write data to flat files, and are suitable for moderate volumes of data and write activity.

For large volume persistent data, needing both high performance and file storage, you may need to store the data in both hash tables for read access and {ini files for write storage.

If you need advice before coding, why not ask for advice in one of the mIRC scripting channels on IRC.

History

Khaled Mardam-Bey first began development on mIRC in 1994. The original goal for mIRC's creation was to solve the main issues that haunted some of the earlier IRC clients, which were plagued with steep learning curves, limited feature sets, and other notable issues[1]. The first public version of mIRC was released on the 28th of February, 1995[1]. The mIRC scripting language grew as commands were added on an ad-hoc basis. Only commands that were directly related to IRC were originally added; however, this slowly changed as the need for more customization grew.

Throughout the 3.0 - 4.0 versions, mSL gained most of the syntax we are familiar with today. Because of the ambiguous nature of the language, such as no real tokens, the use of sigils was introduced in order to distinguish meaningful tokens from plain text tokens. The '$' sigil was introduced to indicate that the token is an identifier. The language began gaining traction when variables were added in version 4.0[2]. Variables are preceded by the '%' sigil. Later on, in version 4.1, the concatenation operator was added, which looks like '$+'.

One of the largest updates to the mIRC scripting language took place in version 4.5, which brought evaluation brackets, aliases in remotes, goto statements, string manipulation, identifiers, if statements and operators, as well as variable assignment arithmetic.

mIRC 4.6 to 5.0 brought a stream of new identifiers and commands to perform more complex operations. Version 5.0 also introduced new custom windows, which gave scripters the ability to create customized mIRC windows.

mIRC 5.3 saw the introduction of sockets and picture windows, which were introduced in order to allow scripts the ability to have graphical user interfaces. In version 5.5, dialogs were added which allowed native-looking components to be added onto a window, such as buttons, check boxes and list boxes.

mIRC 7.0 brought about Unicode support into the language.

References