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 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 | + | 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>. |
− | Code is embedded among plain text and is evaluated | + | 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 | + | 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. |
− | <source lang=mirc> | + | <source lang=mirc>var %variable this is some text, %2ndbar this is more text</source> |
− | There | + | 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 <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. | + | 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 word using <code>$gettok(hello world IMAGiNE, 3, 32)</code>. |
== 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 | + | 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 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}}. |