Delphi 7 if it matters.
procedure writeLog ( varName, varValue: string );
var
length, i :Integer;
begin
Append( logFile );
ShowMessage (varName);
For i := Length(varName) to 20 do //line 37
begin
varName := varName + ' ';
end;
WriteLn( logFile, varName + ': ' + varValue );
CloseFile( logFile );
end;
I get the error:
[Error] felirat.dpr(37): Missing operator or semicolon
All the semicolons seem just fine to me. What am I missing?
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:
len
. System.Length()
. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With