|
![]() | 作者: yuki [gzyomi]
![]() |
登录 |
打开一文本,内容没有字段,就是按顺序排列的多行20位数据,要对此数据进行筛选出不重复的中间第5位开始到12位的数据,筛选出来的内容另存为一个文本文件。 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,StdActns, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure GetSZText; function StrInList(const Idx: Integer; const str: string; const LST: TStringList): Boolean; var i: Integer; begin for i := 0 to LST.Count - 1 do begin if i <> Idx then Result := Copy(LST.Strings[i], 5, 7) = str; if Result then break; end; end; const nbsp = #13#10; var i: Integer; sFileName, sz, sTarget: string; lstElement: TStringList; begin lstElement := TStringList.Create; with TFileOpen.Create(nil) do try if Dialog.Execute then sFileName := Dialog.FileName; finally Free; if (sFileName = '') then exit; end; with lstElement do try LoadFromFile(sFileName); for i := 0 to Count - 1 do begin sz := Strings[i]; sz := Copy(strings[i], 5, 7); if not StrInList(i, sz, lstElement) then sTarget := sTarget + sz + nbsp; end; finally Clear; Text := sTarget; SaveToFile('e:\Target.txt'); Free; end; end; procedure TForm1.Button1Click(Sender: TObject); begin GetSzText; end; end. 错误提示 Warning] Unit1.pas(34): Return value of function 'StrInList' might be undefined [Error] Unit1.pas(52): Cannot BREAK, CONTINUE or EXIT out of a FINALLY clause [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas' 帮我看看如何修正。谢谢 |
地主 发表时间: 04-09-21 08:38 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号