Description |
The SetString procedure sets the length of TargetString to Length before copying that number of characters from the buffer referenced by BufferPointer.
The length is only set when the string is not a ShortString. In fact, the string is reallocated - the TargetString reference is then set to point to this new string.
|
|
Related commands |
FillChar |
|
Fills out a section of storage with a fill character or byte value |
SetLength |
|
Changes the size of a string, or the size(s) of an array |
StringOfChar |
|
Creates a string with one character repeated many times |
|
|
|
Example code : A simple example |
var
target : string;
source : array[1..5] of Char;
srcPtr : PChar;
i : Integer;
begin // Fill out the character array
for i := 1 to 5 do
source[i] := Chr(i+64);
// Copy these characters to a string
srcPtr := Addr(source);
SetString(target, srcPtr, 5);
// Show what we have got
WriteLn('target now = '+target);
end;
|
Show full unit code |
target now = ABCDE
|
|