<<

Contents

Search

>>

 

MID$

 

 

Function and Instruction

 

 

Syntax Function:

MID$(<String Expression>,<Position>[,<Count>])

 

<String Expression>

= <STRING-EXPRESSION>

<Position>

= <NUM-EXPRESSION>

<Count>

= <NUM-EXPRESSION>

 

Syntax Instruction:

 

MID$(<String Expression>,<Position>[,<Count>]) = <String>

 

<String Variable>

= <STRING-VARIABLE

<Position>

= <NUM-EXPRESSION>

<Count>

= <NUM-EXPRESSION>

<String>

= <STRING-EXPRESSION>

 

Meaning:

The function MID$ returns a character string consisting of the characters from <String Expression> from <Position> in the length <Count>. If <Count> is not specified or is bigger than the number of the remaining characters, all characters from <Position> are returned as result.

 

The instruction MID$ replaces in the variable <String Variable> the characters from <Position> in the length <Count> by the characters of <String>. If <Count> is not specified, as many characters as there are in <String> are replaced from <Position>, but not more than there were in the original character string.  

 

Parameter:

String Expression

String expression

String Variable

String variable

Position

Position

Count

Number of characters to replace

 

Sample:

H1$ = "Hello Mrs. Smith"

H2$ = MID$(H1$,7,4)    /* H2$ contains "Mrs."

MID$(H1$,7,4) = "John" /* H1$ contains "Hello John Smith"

 

See also:

LEFT$

RIGHT$ 

INSTR