From WikiChip
Difference between revisions of "mirc"

(this page is over the top but i am building on someone else's work not replacing it.)
m (Undo cat-on-keyboard change)
 
(7 intermediate revisions by 3 users not shown)
Line 10: Line 10:
 
== 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 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. So back to if '2010' is greater, equal, or less than 2010 (noquotes) then you would be comparing character mapping 50 (text '2') to the digital value 2 where 2 means 2 but 2010 means 2 then 0 then 1 then 0.  Compared to '2010' which is 50 then 48 then 49 then 48. Then you can see the quoted numbers are much larger and only one character is checked at a time, the maximum value a number can have is 9 compared to a colossal 57 (quoted text number 9).  Unquoted numbers get used at face value one at a time from left to right first of the two compared character map value and digit face value that is largest first wins the "greater-than is $true" test.  In some programming languages even 100 us considered smaller than only 5 because the 1 is a lower digit but not all programming languages work this way.  Conclusion, in mSL there is no quoting of strings and unquoted numbers they just work as you would expect so 5 is less-than 100 always this has an unnoticeable downside in that <code>5 + '100 worlds'</code> could make <code>'5100 worlds'</code> or maybe <code>'105 worlds'</code> and even compute to an error because you are adding a digit to text which you wouldn't do if you were as sane is say Python programmingAs plus is to math as it is to join together, in most cases. But mSL has another idea for this dilemma and that is {{mirc|identifiers}}.
+
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> commandIf 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> 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 number is mixed right in to the plain text you do not need to convert the number 2 to plain text any further than just however you have it already. 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.  Here number 2 is mapped as character ascii value 50 not as the digit 2 which would normally be kept separate from plain text or specially programmed as converted digit 2 into plain text '2'.  It may sound complicated but thats because we are not describing mSL we are describing most other programming languages. There is a difference between appearance and comparison value are different for characters for text strings (large numbers) and just straight up value for digits from left to right one at a time maximum comparison value of just 9 (numbers compare one digit at a time from left to right).
+
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 ==
 
== 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 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>!=</code> (equals and not-equals) comparison but not greater-than or less-than comparison (with mixed data types it is prone to coding error).
+
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>
 
<source lang=mirc>/var %variable = this is some text value, %2ndbar this is more text value</source>
  
There is a large number of {{mirc|string manipulation|identifiers that can operate on strings}} - anything from {{mirc|$len|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 {{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>.
+
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 with you must use the number 32 (its character map).
+
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 ==
 
== Data Storage ==
Line 35: Line 35:
 
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 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.
+
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}}.
 
{{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}}.

Latest revision as of 16:47, 1 August 2023

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[edit]

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[edit]

Main articles: mSL If Statements, mSL Looping Statements, and 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 identifiers of which you can make your own and they usually return some plain text or returns nothing or does a /halt which stops your script from processing code any further than the identifiers /halt command. If it is an on event happening then mSL still processes all script.mrc files.

Code is embedded among plain text and is evaluated to plain text. For example One $calc(1+1) Three The result will be One 2 Three. 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[edit]

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 forever until manually removed, or local - which are automatically forgotten after returning from an event or an alias call. Local variables are defined using the /var command and global variables with the /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 identifiers that operate on numbers and the /if command does NOT work well with non-number and number mixed text data; aside from a direct == and isin (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).

/var %variable = this is some text value, %2ndbar this is more text value

There are a large number of identifiers that can operate on strings - anything from 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 $left identifier can be used to obtain a portion from the left side of the string - e.g., $left(Hello!!, 4) will yield result 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. One can treat spaces as a delimiter and thus have a list and use $gettok to obtain the 3rd word using $gettok(hello world IMAGiNE, 3, 32). 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[edit]

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. 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 such as 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 hard coded storage of values you can shorten your plain text to an 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 {ini files.

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

History[edit]

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.

The Scripting Community[edit]

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).

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 talk page.

References[edit]