Re: copy one character from a string.



> S2:=S1; // S2 now points to S1, only one instance exists in memory. The
> string has a refcount of 2.
>
> S2[1]:='X'; // S2 is now copied into a newly allocated string, both S1 and
> S2 having a refcount of 1.

Or alternatively ...

S2:=S1; // S2 now points to S1, only one instance exists in memory.
The
string has a refcount of 2.
SetLength(S2, Length(S2)); // S2 is now copied into a newly allocated
string, both S1 and
S2 having a refcount of 1.

Or you could look up SetLength in Delphi Help for a full biography of
SetLength() <g>.

Alan Lloyd

.