March 2000
Intermediate to advanced
576 pages
18h 13m
English
Length Function
function Length(const S: String): Integer; function Length(const A: array): Integer;
Length returns the number of elements in a string
or array. It is not a real function.
Although Length is most often used to learn the
length of a dynamic array, you can also call
Length to find the length of an open array
parameter or even a static
array.
For an array, Length(A) always returns
Ord(High(A))
-
Ord(Low(A))
+
1. For a ShortString, however,
Length returns the value stored in the length
byte, which might be shorter than the string size.
// Toggle case of a string.
procedure ToggleCase(var S: string);
var
I: Integer;
begin
for I := 1 to Length(S) do
if S[I] in ['a'..'z'] then
S[I] := UpCase(S[I])
else if S[I] in ['A'..'Z'] then
S[I] := DownCase(S[I]);
end;| High Function, Low Function, SetLength Procedure, SizeOf Function |
Read now
Unlock full access