Futurebasic/Language/Reference/MID statement
MID$ and MID$$
editSyntax
editMID$(stringVar$,startPos,numChars) = replaceString$
MID$$(container$$,startPos,numChars) = ¬
replaceString$/contnr$$
Revised
editMay 30, 2000 (Release 3)
Description
editThis statement updates stringVar$
(which must be a string variable) or container$$
(a container variable), deleting a subpart from stringVar$
or container$$
and replacing it with an equal number of characters from the left side of replaceString$
. The subpart to be replaced begins at position startPos
within stringVar$
or container$$
. In the following code fragments, containers and strings work the same. The number of characters replaced equals the smallest of these quantities:
numChars
LEN(replaceString$)
LEN(stringVar$) - startPos + 1
Under the following circumstances, MID$
does nothing:
- When
stringVar$
orreplaceString$
is empty; - When
startPos
is less than 1 or greater thanLEN(stringVar$)
; - When
numChars
is less than 1.
Note: You may not use complex expressions that include containers on the right side of the equal sign.
Example:
x$ = "abcdefgh"
y$ = "abcdefgh"
z$ = "abcdefgh"
MID$(x$,2,3) = "1234"
PRINT x$
MID$(y$,2,5) = "1234"
PRINT y$
MID$(z$,7,4) = "1234"
PRINT z$
program output:
a123efgh
a1234egh
abcdef12
See Also
editMID$ function; LEFT$; RIGHT$; INSTR