[문제점]
화일에서 프로그램으로 레코드구조 형식으로 받아
처리하려 하는데.. 에러가 발생합니다.
값과 텍스트 파일의 길이 위치입니다.
1 5 6 16 17 18 26
--------------------------------
5011 부품1 1 850,000
5021 부품2 1 920,000
화일로 저장되어 있을때 이것을 프로그램에 입력 받아
계산하여 스트링그리드로 출력하려 할려고하는데 잘되지
않고 화면이 깨져서 출력됩니다.
화일은 텍스트로 저장되어 있습니다..
어디가 잘 못되었는지 모르겠네요.. 아시는 분
알려주시면 정말 감사하겠습니다..
소스입니다..
const
FILE1NAME ='Part1.txt'; //파일명을 지정
{$R *.DFM}
type // 부품파일을 레코드구조로 선언
Part1Table = Record
Part1Number : string[4];
Part1Name : string[10];
character : string[1];
P1UnitCost : string[8];
end;// End of Part1Table ;
var // File 변수 선언
Part1File : File of Part1Table; //레코드형 화일 선언
Part1Data : Part1Table;//레코드형 변수 선언
dno : integer;
procedure TfrmTest038.Button2Click(Sender: TObject);
var
no : integer;
begin
no := 0;
while Not Eof(Part1File) do
begin
seek(Part1File,no);
read(part1File,Part1Data);
with frmTest038_Out.StringGrid1 do
begin
Cells[0,RowCount-1] := Part1Data.Part1Name ;
Cells[1,RowCount-1] := Part1Data.Part1Number;
Cells[2,RowCount-1] := Part1Data.character;
Cells[3,RowCount-1] := Part1Data.P1UnitCost;
frmTest038_Out.StringGrid1.RowCount:=frmTest038_Out.StringGrid1.RowCount + 1;
inc(no);
end; //end of with
end;//End of While
Closefile(part1File);
frmTest038_Out.Show;
end;
procedure TfrmTest038.FormCreate(Sender: TObject);
begin
editClear; // 화면을 clear
AssignFile(Part1File,FILE1NAME);
if FileExists(FILE1NAME) then
Reset(Part1File)
else
begin
ShowMessage('경고! *.txt File이 하나(또는 둘)가 존재하지 않읍니다!');
end;
close;
end;
|