Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
procedure SetLength(var S; Length1: Integer [; Lenght2: Integer]);
Changes the size of a dynamic array or a string.
S is a string or dynamic-array variable.
If S is a multidimensional dynamic array, we can pass on or more lenghts to the procedure.
For a short-string variable, SetLength simply sets the length-indicator character (the character at S[0]) to the given value. In this case, NewLength must be a value between 0 and 255.
//create an integer vector of N elements
type
TVector = array of integer;
procedure SetVector(var V: TVector; N: integer);
var i: integer;
begin
SetLength(V,N);
for i:= 0 to N-1 do
N[i]:= N-1-i;
end;
//if N=6 then v={5,4,3,2,1,0};
|
String Types in Delphi
Understanding and managing string data types in Delphi's Object Pascal. Learn about differences between Short, Long, Wide and null-terminated strings.
Arrays in Object Pascal
Understanding and using array data types in Delphi.
SetString, BoolToStr
|
Free Delphi code snippet inside every Delphi Newsletter! |
|
|
|
Got some code to share? Got a question? Need some help? |
|
|