PLEASE TRY NOT THE YELL AT THE SCREEN IM ONLY A HIGHSCHOOL STUDENT! lol
I’m writing code for a multi device application in Delphi 11 that will read from a RTF text file
but when running it I get a error (I/O error 13).
This stumped me and I don’t really know what to do to fix it?
Here is the code that will make you vomit.
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<string>;
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;
I put it in the Internal storageDocumentsdelaryroutefix.rtf
and
Internal storagestorageemulatedDocumentsdelaryroutefix.rtf
(note file location got from my pc)
and
…..nothing…gave up?
Arion Swanepoel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.