Difference between revisions of "MC-Basic:MID$"
Line 68: | Line 68: | ||
* [[MC-Basic:LEFT$|LEFT$]] | * [[MC-Basic:LEFT$|LEFT$]] | ||
* [[MC-Basic:RIGHT$|RIGHT$]] | * [[MC-Basic:RIGHT$|RIGHT$]] | ||
− | [[Category | + | [[Category:MC-Basic:String Manipulation|MID$]] |
}} | }} |
Latest revision as of 09:17, 22 May 2014
The MID$ function returns the specified number of characters from the string, starting at the character at position <start>. If <start> is greater than the length of <string>, the returned <string> is empty.
In UTF-8 supporting versions 4.5.1 and higher NULL characters are no longer cut out from strings, resulting in a different behavior:
The string resulting from concatenation is composed from 'A\0B', i.e. there is a NULL character in the MIDDLE of the string:
Display cuts the string in the middle NULL:
-->?"A" + Chr$(0) + "B" A
Mid$ gives NULL for the second character:
-->?Mid$("A" + Chr$(0) + "B", 2, 1) -->
Value of Len is 3:
-->?Len("A" + Chr$(0) + "B") 3.000000000000000e+00
Len of Chr$(0) is 1:
In former versions NULL characters could not appear in the middle of strings, since theconcationation process cut these characters from the resulting string.
Syntax
MID$(<string>, <start>, <number>)
Availability
All versions
Type
<return value>: String
<string>: String
<start>: Long
<number>: Long
Range
<return value>: String
<string>: String
<start>: 1 to MaxLong
<number>: 0 to MaxLong
Scope
Configuration, Task or Terminal
Limitations
Read only.
Examples
-->MID$("Hello", 2, 3) ell