kasieak Posted January 28, 2013 Report Share Posted January 28, 2013 Witam, muszę napisać program, który będzie konwertował plik txt na dxf (autocad), jednak programowanie to nie jest moją mocną stroną. Wyskakuje mi, że projekt został poprawnie zbudowany lecz gdy klikam na "konwertuj" odzywa się debuuger na linijce ile:=strtoint(s); i mówi "Project project1 raised exception class 'EconverError' with message: liczba puntkow 3 is an invalid integer" Mój plik txt wygląda tak: liczba punktow 3 x1 0 y1 0 x2 100 y2 100 x3 100 y3 0 liczba punktow 4 x1 50 y1 50 x2 20 y2 20 x3 20 y3 50 x4 50 y4 20 liczba punktow 3 x1 15 y1 40 x2 90 y2 10 x3 90 y3 74 zaś "program", który napisałam tak: unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; Image1: TImage; procedure Button1Click(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); var f,g:textfile; s:string; x1,y1,ile,xn,yn,i:integer; begin assignfile(f,'dzialki.dxf'); Rewrite(f); Writeln(f,'0'); Writeln(f,'SECTION'); Writeln(f,'2'); Writeln(f,'HEADER'); Writeln(f,'9'); Writeln(f,'$ACADVER'); Writeln(f,'1'); Writeln(f,'AC1027'); Writeln(f,'9'); Writeln(f,'$ACADMAINTVER'); Writeln(f, '70'); Writeln(f, '8'); Writeln(f, '9'); Writeln(f,'$DWGCODEPAGE'); Writeln(f,'3'); Writeln(f,'ANSI_1250'); Writeln(f,'$LASTSAVEDBY'); Writeln(f, '1'); Writeln(f,'ENDSEC'); Writeln(f,'ENTITIES'); assignfile(g,'dzialki.txt'); reset(g); repeat readln(g,s); ile:=strtoint(s); readln(g,s); x1:=strtoint(s); readln(g,s); y1:=strtoint(s); image1.canvas.MoveTo(x1,y1); for i:=2 to ile do begin readln(g,s); xn:=StrToint(s); readln(g,s); yn:=StrToint(s); Image1.Canvas.LineTo(xn,yn) end; Image1.Canvas.LineTo(x1,y1); until eof (g); writeln(f,'0'); writeln(f,'ENDSEC'); writeln(f,'0') ; writeln(f,'EOF'); closefile(f); closefile(g); end; end. until ; end; end. Może ma ktoś, jakiś pomysł co tu jest źle i jak to naprawić ? Z góry dziękuję za pomoc ! Link to comment Share on other sites More sharing options...
5corpio Posted January 28, 2013 Report Share Posted January 28, 2013 Błąd wynika z tego, że próbujesz skonwertować cały string: "liczba puntkow 3" na liczbę int a tak się nie da. Musisz tą linijkę jakoś sparsować. Najprościej rozdzielić po spacjach albo jak tam wolisz i wydobyć samą cyfrę "3" i ją zamienić do int. Ot taka mini-strona moja po godzinach http://www.wnetrzekuchni.pl Link to comment Share on other sites More sharing options...
olesio Posted January 30, 2013 Report Share Posted January 30, 2013 Mam "deżawi". Identyczny wątek był w chyba tym samym czasie na 4p. Tam autor dostał już stosowne wyjaśnienia. I oczywiście zwrócono uwagę na ten sam powód błedu. Pozdrawiam: olesio Link to comment Share on other sites More sharing options...
5corpio Posted January 30, 2013 Report Share Posted January 30, 2013 Jak się nie wie co się pisze to się pisze o tym wszędzie Ot taka mini-strona moja po godzinach http://www.wnetrzekuchni.pl Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.