From WikiChip
Editing mirc

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{mirc guide}}{{title|mIRC Scripting Language}}[[File:mirc logo.png|left|64px]]
+
{{mIRC menu}}{{DISPLAYTITLE:mIRC Scripting Language}}
The '''mIRC Scripting Language''', abbreviated as '''mSL''', is an [[event-driven]], [[procedural programming paradigm|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.
+
The '''mIRC Scripting Language''', abbreviated as '''mSL''', is an [[event-driven]], [[procedural programming paradigm|procedural]] [[scripting language]] embedded inside the [[Wikipedia:mIRC|mIRC client]]. mSL's main feature is its seamless ability to interact with other IRC clients on IRC in order to perform certain 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 {{mirc|com|COM scripts}} and {{mirc|dll|DLLs}}, mSL can be further extended to automate just about everything in the Windows environment.
+
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. mIRC scripts are stored in plain text files (.mrc) or as INI files. With the aid of COM scripts and DLLs, mIRC can be used to automate just about everything in the Windows environment.
 
 
== Overview ==
 
{{main|mirc/introduction|l1=Introduction to mSL}}
 
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 ==
 
{{main|mirc/conditional_statements|mirc/while_loops|mirc/operators|l1=mSL If Statements|l2=mSL Looping Statements|l3=mSL Operators}}
 
mSL is a unique programming language that is coded with just plain text.  Other programming languages are coded in plain text but they all require special syntax which require declaring plain text by putting quotes around it and text code that gets executed is declared being VERY specific about its nature. What I mean is '2010' (quoted) and 2010 (unquoted) are not equal in programming languages other than mSL because each letter, number, symbol is referenced by a number in a range from 1-127 for simple text. So the number 2 is assigned character number 50 (i know its a big number) and the zero is mapped to character number 48.  The digital mappings only go from 1 to 9 as 10 would be a combination of character 49 (one) and 48 (zero) or ONE then ZERO but NOT one & zero.  Conclusion, in mSL there is no quoting of strings and unquoted numbers they just work as you would expect.  As you can guess mSL has another idea for this dilemma and that is {{mirc|identifiers}} of which you can make your own and they usually return some <code>plain text</code> or returns nothing or does a <code>/halt</code> which stops your script from processing code any further than the identifiers <code>/halt</code> command.  If it is an <code>on event</code> happening then mSL still processes all script.mrc files.
 
 
 
Code is embedded among plain text and is evaluated to plain text. For example <code>One $calc(1+1) Three</code> The result will be <code>One 2 Three</code>.  The identifier is the $calc() 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 - some of which can be avoided.
 
 
 
== Variables and text utilities ==
 
{{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 forever until manually removed, or local - which are automatically forgotten after returning from an {{mirc|on events|event}} or an {{mirc|alias|alias call}}.  Local variables are defined using the {{mirc|/var}} command and global variables with the {{mirc|/set}} command. And as we discussed above have no fixed data type in other words they are not forced to contain a specific type of data other than plain text.  In fact everything is more or less treated as plain text with the exception of a handful of {{mirc|identifiers}} that operate on numbers and the {{mirc|/if}} command does NOT work well with non-number and number mixed text data; aside from a direct <code>==</code> and <code>isin</code> (equals-evaluation and contains-text test) but not greater-than or less-than comparison test (with mixed data types it is prone to coding error).
 
 
 
<source lang=mirc>/var %variable = this is some text value, %2ndbar this is more text value</source>
 
 
 
There are a large number of {{mirc|string manipulation|identifiers that can operate on strings}} - anything from {{mirc|$len|determining the length}}, to obtaining a portion of the string from the beginning or end to case transformation and pattern matching. For example, the simple {{mirc|$left}} identifier can be used to obtain a portion from the left side of the string - e.g., <code>$left(Hello!!, 4)</code> will yield result <code>Hell</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. One can treat spaces as a [[delimiter]] and thus have a list and use {{mirc|$gettok}} to obtain the 3rd word using <code>$gettok(hello world IMAGiNE, 3, 32)</code>.  This is 3rd word separated by a space (32) opposed to a comma (44), hyphen (45), period (46), or in the case of filenames backslash (92).  And can be any character you choose to separate your list of words with. Space is mapped to character number 32 since you cannot put a space in to code and expect mSL to find something there to evaluate; you must use the number 32 (its character map).
 
 
 
== Data Storage ==
 
{{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}}
 
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.  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 such as 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 hard coded storage of values you can shorten your plain text to an {{mirc|custom identifier}}.
 
 
 
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 then save and load hash tables to and from {{{mirc|ini files}}.
 
 
 
If you need advice before coding, why not ask for advice in one of the mIRC scripting channels on IRC.
 
  
 
== History ==
 
== History ==
Line 56: Line 17:
 
mIRC 7.0 brought about [[Unicode]] support into the language.
 
mIRC 7.0 brought about [[Unicode]] support into the language.
  
== The Scripting Community ==
+
== Topics ==
 
+
{| valign="top"
In its heyday (in the early noughties), there was a very vigorous mSL scripting community, partly because IRC was the dominant chat service at that time and partly because mIRC allowed you to do stuff (like script your music playing) that media players at the time couldn't do.
+
|-
 
+
|
However more recently, the community has waned somewhat, and many venerable scripts are becoming less compatible with later versions of Windows and mIRC (despite Khaled's commitment to backwards compatibility).
+
*mIRC
 
+
**{{mIRC|Introduction}}
If you are reading this and are interested in being part of an advanced mSL scripting community that will share skills and techniques and revitalise many of the old scripts, then please put your name on my [[User talk:Sophist|talk page]].
+
* Basics
 +
** {{mIRC|Variables}}
 +
** {{mIRC|String Manipulation}}
 +
** {{mIRC|Token Manipulation}}
 +
** {{mIRC|Aliases}}
 +
* Events
 +
** {{mIRC|On events}}
 +
** {{mIRC|Access levels}}
 +
** {{mIRC|Raw Events}}
 +
** {{mIRC|Ctcp Events}}
 +
* Matching Tools
 +
** {{mIRC|Wildcard}}
 +
** {{mIRC|Regex}}
 +
* Data Storage
 +
** {{mIRC|File Handling}}
 +
** {{mIRC|Hash Tables}}
 +
** {{mIRC|INI Files}}
 +
** {{mIRC|Text Files}}
 +
** {{mIRC|Playing music}}
 +
| valign="top" |
 +
* Control Structures
 +
** {{mIRC|Conditional Statements|If Then Else}}
 +
** {{mIRC|Operators}}
 +
** {{mIRC|While Loops}}
 +
** {{mIRC|Goto Statements|Goto Loops}}
 +
* GUI Scripting
 +
** {{mIRC|Custom Windows}}
 +
** {{mIRC|Picture Windows}}
 +
** {{mIRC|Dialogs}}
 +
*** {{mIRC|Dialog Components}}
 +
* Sockets
 +
** {{mIRC|Sockets}}
 +
** {{mIRC|sockets/tcp|TCP Sockets}}
 +
** {{mIRC|sockets/udp|UDP Sockets}}
 +
* Advanced Scripting
 +
** {{mIRC|Eval Brackets }}
 +
** {{mIRC|COM}}
 +
** {{mIRC|DLL}}
 +
** {{mIRC|SendMessage}}
 +
| valign="top" |
 +
* Additional Resources
 +
** {{mIRC|commands|mSL Commands}}
 +
** {{mIRC|identifiers|mSL Identifiers}}
 +
*** {{mIRC|local identifiers|mSL Local Identifiers}}
 +
** {{mIRC|on events|mSL Events}}
 +
** {{mIRC|access levels#Level prefixes|mSL Event Prefixes}}
 +
* Security
 +
** {{mIRC|msl injection|mSL Injection}}
 +
* Others
 +
** {{mIRC|virtual profile|Virtual Profile}}
 +
** {{mIRC|unicode|Unicode}}
 +
** {{mIRC|ipv6|Ipv6}}
 +
|}
  
 
== References ==
 
== References ==
 
{{reflist}}
 
{{reflist}}
  
[[Category: mIRC|mSL]]
+
[[Category: mIRC]]

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)