Я пишу код для приложения для нескольких устройств в Delphi 11, которое будет читать из текстового файла RTF.
При его запуске я получаю ошибку ввода-вывода 13. Это поставило меня в тупик, и я даже не знаю, что делать, чтобы это исправить.
Вот мой код:
procedure TForm2.btnCalculateClick(Sender: TObject);
const
p = 1.225; // Air density (kg/m^3)
A = 1.03; // Frontal area (m^2)
g = 9.81; // Acceleration due to gravity (m/s^2)
var
v_kmh, vw_kmh, v, vw, θ, ηmotor, Paux, m, Cr, Cd: Double;
F1, F2, F3, Ploss: Double;
//Elevation thingy
Locations: array of Integer;
InputFile: TextFile;
Line: string;
Elevation, I: Integer;
Angle: Double;
Parts: TArray;
FileName: string;
begin
memDebug.Lines.Clear;
// Get values
v_kmh := SpinBox1.Value; // Speed of the car (km/h)
vw_kmh := SpinBox2.Value; // Wind speed (km/h)
θ := SpinBox3.Value * (Pi / 180); // Convert angle to radians
Paux := StrToFloat(edtAuxloss.Text);
FileName := TPath.Combine(TPath.GetSharedDocumentsPath, 'delary/routefix.rtf');
if FileExists(FileName) then
begin
AssignFile(InputFile, FileName);
Reset(InputFile);
try
while not Eof(InputFile) do
begin
Readln(InputFile, Line);
if Pos('Elevation:', Line) > 0 then
begin
Parts := Line.Split([' ']);
Elevation := StrToInt(Trim(Parts[High(Parts)])); // Extracting the last part as the elevation
SetLength(Locations, Length(Locations) + 1);
Locations[High(Locations)] := Elevation;
end;
end;
for I := 0 to High(Locations) - 1 do
begin
Angle := ArcTan((Locations[I + 1] - Locations[I]) / 1); // Assuming horizontal distance is 1 unit
memDebug.Lines.Add(Format('Angle between point %d and %d: %.2f degrees', [I, I + 1, Angle * (180 / Pi)]));
end;
finally
CloseFile(InputFile);
end;
end
else
begin
memDebug.Lines.Add('File not found: ' + FileName);
end;
Я поместил его во Внутреннее хранилище\Documents\delary\routefix.rtf и Внутреннее хранилище\storage\emulated\0\Documents\delary\routefix.rtf (местоположение файла заметки получено с моего компьютера) и
... ничего.
Я пишу код для приложения для нескольких устройств в Delphi 11, которое будет читать из текстового файла RTF. При его запуске я получаю ошибку ввода-вывода 13. Это поставило меня в тупик, и я даже не знаю, что делать, чтобы это исправить. Вот мой код: [code]procedure TForm2.btnCalculateClick(Sender: TObject); const p = 1.225; // Air density (kg/m^3) A = 1.03; // Frontal area (m^2) g = 9.81; // Acceleration due to gravity (m/s^2) var v_kmh, vw_kmh, v, vw, θ, ηmotor, Paux, m, Cr, Cd: Double; F1, F2, F3, Ploss: Double;
memDebug.Lines.Clear; // Get values v_kmh := SpinBox1.Value; // Speed of the car (km/h) vw_kmh := SpinBox2.Value; // Wind speed (km/h) θ := SpinBox3.Value * (Pi / 180); // Convert angle to radians Paux := StrToFloat(edtAuxloss.Text);
FileName := TPath.Combine(TPath.GetSharedDocumentsPath, 'delary/routefix.rtf'); if FileExists(FileName) then begin AssignFile(InputFile, FileName); Reset(InputFile); try while not Eof(InputFile) do begin Readln(InputFile, Line); if Pos('Elevation:', Line) > 0 then begin Parts := Line.Split([' ']); Elevation := StrToInt(Trim(Parts[High(Parts)])); // Extracting the last part as the elevation SetLength(Locations, Length(Locations) + 1); Locations[High(Locations)] := Elevation; end; end; for I := 0 to High(Locations) - 1 do begin Angle := ArcTan((Locations[I + 1] - Locations[I]) / 1); // Assuming horizontal distance is 1 unit memDebug.Lines.Add(Format('Angle between point %d and %d: %.2f degrees', [I, I + 1, Angle * (180 / Pi)])); end; finally CloseFile(InputFile); end; end else begin memDebug.Lines.Add('File not found: ' + FileName); end; [/code] Я поместил его во Внутреннее хранилище\Documents\delary\routefix.rtf и Внутреннее хранилище\storage\emulated\0\Documents\delary\routefix.rtf (местоположение файла заметки получено с моего компьютера) и ... ничего.