Jump to content

txt na dxf


kasieak

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...