Jump to content

Futurebasic/Language/Reference/MID statement

From Wikibooks, open books for an open world

MID$ and MID$$

[edit | edit source]

Syntax

[edit | edit source]

MID$(stringVar$,startPos,numChars) = replaceString$ MID$$(container$$,startPos,numChars) = ¬   replaceString$/contnr$$

Revised

[edit | edit source]

May 30, 2000 (Release 3)

Description

[edit | edit source]

This 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$ or replaceString$ is empty;
  • When startPos is less than 1 or greater than LEN(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

[edit | edit source]

MID$ function; LEFT$; RIGHT$; INSTR