All pastes #22039 Raw Edit

c03

public text v1 · immutable
#22039 ·published 2005-09-03 15:50 UTC
rendered paste body
unit 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);
  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
StringReplace(fileData, "a", "7", [rfReplaceAll]);
StringReplace(fileData, "e", "1", [rfReplaceAll]);
StringReplace(fileData, "n", "3", [rfReplaceAll]);
StringReplace(fileData, "c", "2", [rfReplaceAll]);
StringReplace(fileData, "f", "4", [rfReplaceAll]);
StringReplace(fileData, "t", "5", [rfReplaceAll]);
StringReplace(fileData, "o", "6", [rfReplaceAll]);
StringReplace(fileData, "l", "8", [rfReplaceAll]);
StringReplace(fileData, "m", "9", [rfReplaceAll]);
StringReplace(fileData, "u", "0", [rfReplaceAll]);
StringReplace(fileData, "r", "<", [rfReplaceAll]);
StringReplace(fileData, "h", ">", [rfReplaceAll]);
StringReplace(fileData, "p", "©", [rfReplaceAll]);
StringReplace(fileData, "y", "†", [rfReplaceAll]);
StringReplace(fileData, "g", "*", [rfReplaceAll]);
StringReplace(fileData, "d", "!", [rfReplaceAll]);
StringReplace(fileData, "w", "&", [rfReplaceAll]);
StringReplace(fileData, "h", "=", [rfReplaceAll]);
StringReplace(fileData, "i", "#", [rfReplaceAll]);
end;

end.