FutureBasic Logo

<<    Index    >> FutureBasic 5

mid$ and mid$$   statement



Syntax:
mid$(PascalStringVar,startPos,numChars) = replacePascalString
mid$$(container$$,startPos,numChars) = ¬
  replacePascalString/contnr$$


Description:
This statement updates PascalStringVar (which must be a string variable) or container$$ (a container variable), deleting a subpart from PascalStringVar or container$$ and replacing it with an equal number of characters from the left side of replacePascalString. The subpart to be replaced begins at position startPos within PascalStringVar or container$$. In the following code fragments, containers and strings work the same. The number of characters replaced equals the smallest of these quantities:
Under the following circumstances, mid$ does nothing:
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:
mid$ function; left$; right$; instr