I try to rewrite my old Turbopascal MotorCalculation Program in Lazarus.
I have still Problems readig existig files
Here the code
procedure TForm1.MenuItem1Click(Sender: TObject);
var
filename: string;
begin
if OpenDialog1.Execute then
begin
filename := OpenDialog1.Filename;
ShowMessage(filename);
ReadFile( filename); ;
end;
end;
And here is the Procedure Readfile
{---------------------------------------------------------------------------}
PROCEDURE TForm1.ReadFile( var filevar: string);
VAR
LocalMotorname:String;
ok:Boolean;
Answer :Char;
BEGIN
REPEAT
LocalMotorname:='????????.MOT';
{DirList; }
WRITELN;
WRITELN('NAME OF FILE TO BE LOADED ?(without extension) ');
READLN(LocalMotorname);
LocalMotorname:= StringUpper(LocalMotorname);
WritelN(LocalMotorname);
LocalMotorname := LocalMotorname + '.MOT';
ok:=false;
StringUpper(LocalMotorname);
writeln;
WRITELN((LocalMotorname),' FILE WILL BE LOADED');
IF NOT FileExists(LocalMotorname)
THEN
BEGIN
WRITELN('CAN NOT find file :',LocalMotorname);
WRITELN;
WRITELN;
ok:=False;
END;
IF FileExists(LocalMotorname) THEN
BEGIN
AssignFile(filevar,LocalMotorname);
And here I get this error
datenfile1.pas(1975,26) Error: Call by var for arg no. 1 has to match
exactly: Got "AnsiString" expected "TypedFile"
What can I do to correct the error ?
TRY
RESET(filevar); // Open the file for reading
and here the other error
datenfile1.pas(1978,31) Error: Call by var for arg no. 1 has to
match exactly: Got "AnsiString" expected "Text"
// Keep reading lines until the end of the file is reached
while not eof(filevar) do
BEGIN
READLN(filevar,dia);
READLN(filevar,mes);
READLN(filevar,anho);
READLN(filevar,motortyp);
READLN(filevar,Bearbeiter);
READLN(filevar,Statorblechnr);
READLN(filevar,Rotorblechnr);
READLN(filevar,Angebotsnummer);
READLN(filevar,kenrot);
READLN(filevar,schltg);
READLN(filevar,polzahl);
READLN(filevar,motfil);
READLN(filevar,pabkw);
READLN(filevar,uv);
READLN(filevar,freq);
READLN(filevar,cosphi);
READLN(filevar,etam);
READLN(filevar,delta);
READLN(filevar,N1);
READLN(filevar,n2);
{some 20 Variable more in the same line}
READLN(filevar,Brst25);
READLN(filevar,Rst25);
{ReadData End}
ok:=true;
END;
except on E: EInOutError do
writeln('File handling error occurred. Details: ', E.Message);
end;
CloseFile(filevar);
writeln('File ', LocalMotorname, ' was read. Press enter to continue.');
readln;
Motorname:=LocalMotorname;
WriteDataToScreen;
END;
WRITELN(LocalMotorname,' loaded. Do you want to load another Motor File
instead?(Y/N) ');
readln;
If Answer= 'Y' Then ok:= False Else ok:= True;
UNTIL ok=True;
END;
datenfile1.pas(1975,26) Error: Call by var for arg no. 1 has to match
exactly: Got "AnsiString" expected "TypedFile"
Where arises the Type mismatch?
Has someone a better example how to read old archives in Lazarus with new components, but using the existing files?(They are Motor Calculation files and it would be very tiresome to write them again)
Help would be appreciate