From WikiChip
Difference between revisions of "mirc/identifiers/$mid"
Maroonbells (talk | contribs) m (Blanked the page) |
Maroonbells (talk | contribs) m |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | {{mirc title|$mid Identifier}}'''$mid''' is a {{mIRC|string manipulation}} identifier used to return a sub-string portion of a string. | ||
+ | == Synopsis == | ||
+ | * '''$mid(<text> ,S [, N ] )''' | ||
+ | |||
+ | == Parameters == | ||
+ | * '''text''' String from which to return a portion | ||
+ | * '''S''' Position within Text. If S is negative, position is relative to the end of Text instead of the beginning. Using Zero behaves same as position 1. | ||
+ | * '''N''' Optional Length. If Length parameter not used, returns entire remainder of the string. If N is zero, returns the numeric length of the string. If N is negative, returns the string beginning at position S except for the LAST $Abs(N) characters. | ||
+ | |||
+ | == Properties == | ||
+ | |||
+ | None | ||
+ | |||
+ | == Examples == | ||
+ | <source lang="mIRC">//echo -a $mid(abcdefghij,2,3) | ||
+ | returns 3 characters beginning at position 2</source> | ||
+ | |||
+ | <source lang="mIRC">//echo -a $mid(abcdefghij,2) | ||
+ | //echo -a $mid(abcdefghij,2,9999) | ||
+ | both return ALL characters beginning at position 2. Omitting N avoids the need to use N as a too-large number like 9999</source> | ||
+ | |||
+ | <source lang="mIRC">//echo -a $mid(abcdefghij,-6,2) | ||
+ | returns 2 characters beginning at position 6th from the end. Is equivalent to: | ||
+ | //echo -a $left($right(abcdefghij,6) ,2) | ||
+ | </source> | ||
+ | |||
+ | <source lang="mIRC">//echo -a $mid(abcdefghij,-6) | ||
+ | returns ALL characters beginning at position 6th from the end. | ||
+ | </source> | ||
+ | |||
+ | <source lang="mIRC">//echo -a $mid(abcdefghij,3,-2) | ||
+ | returns ALL characters beginning at position 3 EXCEPT for the last 2 characters. | ||
+ | </source> | ||
+ | |||
+ | <source lang="mIRC">//echo -a $mid(abcdefghij,3,0) | ||
+ | returns the length of the string beginning at position 3. | ||
+ | </source> | ||
+ | |||
+ | == Compatibility == | ||
+ | {{mIRC compatibility|4.5}} | ||
+ | |||
+ | == See also == | ||
+ | * {{mIRC|string manipulation}} | ||
+ | * {{mIRC|$left}} | ||
+ | * {{mIRC|$right}} | ||
+ | * {{mIRC|$pos}} | ||
+ | * {{mIRC|$str}} |
Latest revision as of 15:52, 19 February 2018
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$mid is a string manipulation identifier used to return a sub-string portion of a string.
Synopsis[edit]
- $mid(<text> ,S [, N ] )
Parameters[edit]
- text String from which to return a portion
- S Position within Text. If S is negative, position is relative to the end of Text instead of the beginning. Using Zero behaves same as position 1.
- N Optional Length. If Length parameter not used, returns entire remainder of the string. If N is zero, returns the numeric length of the string. If N is negative, returns the string beginning at position S except for the LAST $Abs(N) characters.
Properties[edit]
None
Examples[edit]
//echo -a $mid(abcdefghij,2,3) returns 3 characters beginning at position 2
//echo -a $mid(abcdefghij,2) //echo -a $mid(abcdefghij,2,9999) both return ALL characters beginning at position 2. Omitting N avoids the need to use N as a too-large number like 9999
//echo -a $mid(abcdefghij,-6,2) returns 2 characters beginning at position 6th from the end. Is equivalent to: //echo -a $left($right(abcdefghij,6) ,2)
//echo -a $mid(abcdefghij,-6) returns ALL characters beginning at position 6th from the end.
//echo -a $mid(abcdefghij,3,-2) returns ALL characters beginning at position 3 EXCEPT for the last 2 characters.
//echo -a $mid(abcdefghij,3,0) returns the length of the string beginning at position 3.
Compatibility[edit]
Added: mIRC v4.5
Added on: 30 Jun 1996
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.