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

From SoftMC-Wiki
Jump to: navigation, search
(Created page with '{{MC-Basic |SHORT FORM= |SYNTAX= MID$(''<string>, <start>, <number>'') |AVAILABILITY= All versions |DESCRIPTION= The MID$ function returns the specified number of characters …')
 
m (1 revision)
(No difference)

Revision as of 16:09, 13 December 2010

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