You declared a local variable named length
. This local variable hides the function of the same name declared in the System
unit (Delphi, as a Pascal derivative, is case-insensitive). So when you wrote:
For i := Length(varName) to 20 do
the compiler sees Length
as the variable rather than the function. And that leads to your compiler error.
Possible solutions:
- Use a different name for the variable, e.g.
len
. - Use the fully scoped name for the function:
System.Length()
.