rendered paste bodyunit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
TForm1 = class(TForm)
MemoBox: TMemo;
Headline: TLabel;
LoadButton: TButton;
SaveButton: TButton;
EncryptButton: TButton;
DecryptButton: TButton;
Label1: TLabel;
CloseButton: TBitBtn;
AboutButton: TButton;
procedure AboutButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure LoadButtonClick(Sender: TObject);
procedure EncryptButtonClick(Sender: TObject);
procedure SaveButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
fileName : String;
fileData : TStringList;
openDialog : TOpenDialog;
implementation
{$R *.dfm}
procedure TForm1.AboutButtonClick(Sender: TObject);
begin
ShowMessage('This program was developed by Kristian Theilgaard of CK Systems'+#13+#13+'The CK Systems Cooperation was founded in 2005'+#13);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//Deaktiver de unødvendige knapper
EncryptButton.Enabled := False;
DecryptButton.Enabled := False;
SaveButton.Enabled := False;
//Klargør memoboxen
MemoBox.Clear;
MemoBox.ScrollBars := ssBoth;
//Klargør Label1
Label1.Caption := '';
// Create the open dialog object - used by the GetTextFile routine
openDialog := TOpenDialog.Create(self);
// Ask for only files that exist
openDialog.Options := [ofFileMustExist];
// Ask only for text files
openDialog.Filter := 'Text files|*.txt';
// Create the string list object that holds the file contents
fileData := TStringList.Create;
end;
procedure TForm1.LoadButtonClick(Sender: TObject);
begin
if openDialog.Execute then // Did the user select a file?
begin
// Save the file name
fileName := openDialog.FileName;
// Now that we have a file loaded, enable the text correction button
EncryptButton.Enabled := True;
DecryptButton.Enabled := True;
// Load the file into our string list
fileData.LoadFromFile(fileName);
// Display the file in the file display box
MemoBox.Text := fileData.Text;
// Display the number of lines in the file
Label1.Caption := fileName;
end;
end;
procedure TForm1.EncryptButtonClick(Sender: TObject);
begin
//Clear the memobox
MemoBox.Clear;
StringReplace(fileData.text, 'a', '7', [rfReplaceAll]);
StringReplace(fileData.text, 'e', '1', [rfReplaceAll]);
StringReplace(fileData.text, 'n', '3', [rfReplaceAll]);
StringReplace(fileData.text, 'c', '2', [rfReplaceAll]);
StringReplace(fileData.text, 'f', '4', [rfReplaceAll]);
StringReplace(fileData.text, 't', '5', [rfReplaceAll]);
StringReplace(fileData.text, 'o', '6', [rfReplaceAll]);
StringReplace(fileData.text, 'l', '8', [rfReplaceAll]);
StringReplace(fileData.text, 'm', '9', [rfReplaceAll]);
StringReplace(fileData.text, 'u', '0', [rfReplaceAll]);
StringReplace(fileData.text, 'r', '<', [rfReplaceAll]);
StringReplace(fileData.text, 'h', '>', [rfReplaceAll]);
StringReplace(fileData.text, 'p', '©', [rfReplaceAll]);
StringReplace(fileData.text, 'y', '', [rfReplaceAll]);
StringReplace(fileData.text, 'g', '*', [rfReplaceAll]);
StringReplace(fileData.text, 'd', '!', [rfReplaceAll]);
StringReplace(fileData.text, 'w', '&', [rfReplaceAll]);
StringReplace(fileData.text, 'h', '=', [rfReplaceAll]);
StringReplace(fileData.text, 'i', '#', [rfReplaceAll]);
// Display the file in the file display box
MemoBox.Text := fileData.Text;
//Enable the save button again
SaveButton.Enabled := True;
end;
procedure TForm1.SaveButtonClick(Sender: TObject);
begin
// Simply save the contents of the file string list
if fileName <> '' then
fileData.SaveToFile(fileName);
// And disable the file save button
SaveButton.Enabled := false;
end;
end.