【delphi开源代码栏目提醒】:网学会员--在 delphi开源代码编辑为广大网友搜集整理了:Coder.pas绩等信息,祝愿广大网友取得需要的信息,参考学习。
unit Coder;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls;
type
TMainForm = class(TForm)
procedure N5Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
ATextFile:system.TextFile;
implementation
{$R *.dfm}
function Encode(s:String):String;
var
n,i:integer;
str:string;
begin
n:=length(s);
str:='';
for i:=1 to n do
begin
str:=str+Char(Ord(s[i])+20);
end;
encode:=str;
end;
function Decode(s:String):String;
var
n,i:integer;
str:string;
begin
n:=length(s);
str:='';
for i:=1 to n do
begin
str:=str+Char(Ord(s[i])-20);
end;
Decode:=str;
end;
procedure TMainForm.N5Click(Sender: TObject);
begin
Close;
end;
procedure TMainForm.N2Click(Sender: TObject);
var
TextLine:String;
begin
if OpenDialog1.Execute then
begin
ListBox1.Clear;
Caption:='文件加密解密器'+OpenDialog1.FileName;
AssignFile(ATextFile,OpenDialog1.FileName);
Reset(ATextFile);
While not eof(ATextFile) do
begin
Readln(ATextfile,TextLine);
ListBox1.Items.Add(TextLine);
end;
CloseFile(ATextFile);
end;
end;
procedure TMainForm.N3Click(Sender: TObject);
var
LineNo:Integer;
TextLine,NewLine:String;
begin
if SaveDialog1.Execute then
begin
AssignFile(ATextFile,SaveDialog1.FileName);
Rewrite(ATextFile);
For LineNo:=0 to ListBox1.Items.Count-1 do
begin
TextLine:=ListBox1.Items[LineNo];
NewLine:=Encode(TextLine);
Writeln(ATextFile,NewLine);
end;
CloseFile(ATextFile);
end;
end;
procedure TMainForm.N6Click(Sender: TObject);
var
LineNo:Integer;
TextLine,NewLine:String;
begin
if SaveDialog1.Execute then
begin
AssignFile(ATextFile,SaveDialog1.FileName);
Rewrite(ATextFile);
For LineNo:=0 to ListBox1.Items.Count-1 do
begin
TextLine:=ListBox1.Items[LineNo];
NewLine:=Decode(TextLine);
Writeln(ATextFile,NewLine);
end;
CloseFile(ATextFile);
end;
end;
end.
上一篇:
DocManDlg.cpp
下一篇:
4种小菜缓解孕妈咪不适