procedure TForm1.Button1Click(Sender: TObject);
var
MyStrings : TStrings;
OrgString : String;
Fp : TextFile;
i, MyStrCount : integer;
begin
if not OpenDialog1.Execute then Exit;
AssignFile(Fp, OpenDialog1.FileName);
Reset(Fp);
Table1.First;
MyStrings := TStringList.Create;
while Not Eof(Fp) do begin
Table1.Insert;
Readln(Fp, OrgString);
MyStrCount := ExtractStrings([' '],[' '], PChar(OrgString), MyStrings);
Label2.Caption := inttostr(i);
Application.ProcessMessages;
if MyStrCount <= Table1.FieldCount then begin
Table1.Fields[0].Value := MyStrings[0];
Table1.Fields[1].Value := MyStrings[1];
Table1.Fields[2].Value := MyStrings[2];
Table1.Fields[3].Value := MyStrings[3];
Table1.Fields[4].Value := MyStrings[4];
Table1.Fields[5].Value := MyStrings[5];
Table1.Fields[6].Value := MyStrings[6];
end;
Table1.Post;
Table1.Next;
inc(i);
end;
CloseFile(Fp);
MyStrings.Free;
end;
// sValue로 구분된 데이타 iCnt번째 만나면 iSel 값이 0 = 전의 데이타, 1 = 전의 모든 데이타.
function TF_CMNE01D.ValueCut( sText, sValue : String; iCnt, iSel : Integer ) : String;
var
sStr : String;
i, ic : Integer;
begin
sStr := '';
ic := 1;
if sText = '' then Result := ''
else begin
case iSel of
0 : begin
for i := 0 to Length( sText ) do
begin
if sText[ i ] = sValue then Inc( ic );
if iCnt = ic then
begin
sStr := sStr + sText[ i ];
end;
end;
Result := Copy( sStr,2,Length( sStr ) - 1 );
end;
1 : begin
for i := 0 to Length( sText ) do
begin
if sText[ i ] = sValue then
begin
Inc( ic );
if iCnt = ic-1 then Break;
end;
end;
Result := Copy( sText, i+1, Length( sText ) - i );
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MyStrings : TStrings;
OrgString : String;
Fp : TextFile;
i, MyStrCount : integer;
begin
if not OpenDialog1.Execute then Exit;
AssignFile(Fp, OpenDialog1.FileName);
Reset(Fp);
Table1.First;
MyStrings := TStringList.Create;
while Not Eof(Fp) do begin
Table1.Insert;
Readln(Fp, OrgString);
MyStrCount := ExtractStrings([' '],[' '], PChar(OrgString), MyStrings);
Label2.Caption := inttostr(i);
Application.ProcessMessages;
if MyStrCount <= Table1.FieldCount then begin
Table1.Fields[0].Value := MyStrings[0];
Table1.Fields[1].Value := MyStrings[1];
Table1.Fields[2].Value := MyStrings[2];
Table1.Fields[3].Value := MyStrings[3];
Table1.Fields[4].Value := MyStrings[4];
Table1.Fields[5].Value := MyStrings[5];
Table1.Fields[6].Value := MyStrings[6];
end;
Table1.Post;
Table1.Next;
inc(i);
end;
CloseFile(Fp);
MyStrings.Free;
end;
쿼리문을 쓰면 더 간단할 듯...
즐푸~