ReplaceSubstring procedure
Replaces (or appends) the specified number of bytes at a given position.
Declaration
procedure ReplaceSubstring(var s: string; StartPos: SizeInt;
Count: SizeInt; const Insertion: string)Arguments
s | String with values examined and updated in the routine. |
StartPos | Initial byte position in the string where the substitution occurs. |
Count | Number of bytes replaced in the string. |
Insertion | Value inserted (or appended) to the value in the string. |
Description
ReplaceSubstring is a procedure used to replace a portion of a
string with the specified value.
Startpos contains the byte position in S where the substitution is
performed. When StartPos is larger that the number of bytes in S, the value
in Insertion is appended to the existing string value. The initial value in
StartPos is 1.
Count contains the number of bytes in the string to be replaced in
the routine. Count cannot exceed the number of bytes available starting at
StartPos. No actions are performed in the routine when Count is
0
(
zero) and the length of the Insertion parameter is
0
(
zero).
ReplaceSubstring calls CompareMem to determine if the specified
range in S and the value in Insertion have the same content. No actions are
performed when the contain the same values.
The affected byte values in S are transferred by calling the
System.Move routine. SetLength is called to update the
new length for the string.
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
