Difference between revisions of "MC-Basic:MID$"
m (1 revision) |
m (corrected layout) |
||
Line 12: | Line 12: | ||
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. | 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 | + | 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''\0''B', i.e. there is a NULL character in the MIDDLE of the string: | |
− | |||
− | The string resulting from concatenation is composed from 'A''\0''B', i.e. | ||
Display cuts the string in the middle NULL: | Display cuts the string in the middle NULL: | ||
− | -->?"A" + Chr$(0) + "B" | + | -->?"A" + Chr$(0) + "B" |
− | + | A | |
− | A | ||
Mid$ gives NULL for the second character: | Mid$ gives NULL for the second character: | ||
− | -->?Mid$("A" + Chr$(0) + "B", 2, 1) | + | -->?Mid$("A" + Chr$(0) + "B", 2, 1) |
− | + | --> | |
− | --> | ||
Value of Len is 3: | Value of Len is 3: | ||
− | -->?Len("A" + Chr$(0) + "B") | + | -->?Len("A" + Chr$(0) + "B") |
− | + | 3.000000000000000e+00 | |
− | 3.000000000000000e+00 | ||
Len of Chr$(0) is 1: | Len of Chr$(0) is 1: | ||
− | In former versions NULL characters could not appear in the middle of strings, since | + | In former versions NULL characters could not appear in the middle of strings, since theconcationation process cut these characters from the resulting string. |
− | |||
− | theconcationation process cut these characters from the resulting string. | ||
|TYPE= | |TYPE= | ||
Line 67: | Line 60: | ||
|EXAMPLE= | |EXAMPLE= | ||
− | -->MID$("Hello", 2, 3)< | + | <pre> |
− | + | -->MID$("Hello", 2, 3) | |
+ | ell | ||
+ | </pre> | ||
|SEE ALSO= | |SEE ALSO= |
Revision as of 07:11, 26 September 2011
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