Difference between revisions of "MC-Basic:MID$"

From SoftMC-Wiki
Jump to: navigation, search
m (Text replace - "Read-Only" to "Read only")
m (Text replace - "''<number>''" to "<''number''>")
Line 39: Line 39:
 
''<string>'': String<br>
 
''<string>'': String<br>
 
''<start>'': Long<br>
 
''<start>'': Long<br>
''<number>'': Long
+
<''number''>: Long
  
 
|RANGE=
 
|RANGE=
Line 45: Line 45:
 
''<string>'': String<br>
 
''<string>'': String<br>
 
''<start>'': 1 to MaxLong<br>
 
''<start>'': 1 to MaxLong<br>
''<number>'': 0 to MaxLong
+
<''number''>: 0 to MaxLong
  
 
|UNITS=
 
|UNITS=

Revision as of 09:32, 20 March 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

See Also