| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 478 人关注过本帖
标题:[讨论]改成C#语言编写的
只看楼主 加入收藏
dior001
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-8
收藏
 问题点数:0 回复次数:0 
[讨论]改成C#语言编写的

哪位大虾能不能改成C#语言编写的

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, PerlRegEx;

type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Memo1: TMemo;
ListBox1: TListBox;
Panel1: TPanel;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Splitter1: TSplitter;
TabSheet3: TTabSheet;
mExclusion: TMemo;
ListBox2: TListBox;
pcre: TPerlRegEx;
procedure Button1Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
function Excluded(str: string): Boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
uses FileList;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
fl : TFileList;
Content : TStringList;
i, j : Integer;
begin
PageControl1.ActivePageIndex := 0;
ListBox1.Items.Clear;
pcre.RegEx := '''.*?[A-Za-z]+.*?''';
Content := TStringList.Create;
fl := TFileList.Create;
fl.Root := Edit1.Text;
fl.Mask := Edit2.Text;
fl.Recursive := True;
fl.Update;
for i := 0 to fl.Count - 1 do
begin
if Excluded(fl[i]) then
Continue;
Content.LoadFromFile(fl[i]);
pcre.Subject := Content.Text;
if pcre.Match then
repeat
if not Excluded(pcre.MatchedExpression) then
begin
ListBox1.AddItem(fl[i], nil);
Break;
end;
until not pcre.MatchAgain;
end;
fl.Free;
Content.Free;
end;

function TForm1.Excluded(str: string): Boolean;
var
i : Integer;
begin
Result := False;
for i := 0 to mExclusion.Lines.Count - 1 do
begin
if Pos(mExclusion.Lines[i], str) > 0 then
begin
Result := True;
Break;
end;
end;
end;

procedure TForm1.ListBox1DblClick(Sender: TObject);
var
fn : string;
begin
fn := ListBox1.Items[ListBox1.ItemIndex];
try
Memo1.Lines.LoadFromFile(fn);
PageControl1.ActivePageIndex := 1;
except
end;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var
fn : string;
sl : TStringList;
i : Integer;
begin
ListBox2.Items.Clear;
sl := TStringList.Create;
fn := ListBox1.Items[ListBox1.ItemIndex];
try
sl.LoadFromFile(fn);
pcre.RegEx := '''.*?[A-Za-z]+.*?''';
for i := 0 to sl.Count - 1 do
begin
pcre.Subject := sl[i];
if pcre.Match then
begin
if not Excluded(sl[i]) then
ListBox2.AddItem(sl[i], nil);
end;
end;
except
end;
sl.Free;
end;

end.

搜索更多相关主题的帖子: 语言 编写 
2006-05-14 17:33
快速回复:[讨论]改成C#语言编写的
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017223 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved