
|
<<
Index
>>
|
FutureBasic 5
|
|
mid$ and mid$$
|
|
statement
|
|
Syntax:
mid$(stringVar$,startPos,numChars) = replaceString$
mid$$(container$$,startPos,numChars) = ¬
replaceString$/contnr$$
Description:
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:
mid$ function; left$; right$; instr