Einzelnen Beitrag anzeigen

Benutzerbild von Deltachaos
Deltachaos

Registriert seit: 20. Feb 2008
Ort: Berlin
195 Beiträge
 
Delphi 7 Personal
 
#24

Re: Zeichen in Memo ersetzen

  Alt 23. Feb 2008, 16:08
Zitat von DeddyH:
Schau Dir Deine "code"-Funktion nochmal an: Du ersetzt 'a' durch 'toll', dann weiter unten jeden Buchstaben durch einen Leerstring, das kann ja nichts werden. Außerdem solltest Du aus den Prozeduren Methoden machen, so ist das recht unschön
also ich habs erst mal hinbekommen.
is ja auch unlogisch gewesen

erste ersätze ich a durch toll
also toll

und dan werden diese buchstaben ja auch noch ersätzt aber durch gar nichts weil ich da noch nichts reingeschrieben hatte.

Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Memo1: TMemo;
    GroupBox2: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    Label4: TLabel;
    Label5: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    PrintDialog1: TPrintDialog;
    ProgressBar1: TProgressBar;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
key1, key1a, key1b, key2, key2a, key2b, key3, key3a, key3b: string;
i:integer;

procedure _var_;
begin
 i:= 1;
 key1:= form1.edit1.text;
 key2:= form1.edit2.text;
 key3:= form1.edit3.text;
 key1a := Copy(key1,1,2);
 key1b := Copy(key1,3,4);
 key2a := Copy(key2,1,2);
 key2b := Copy(key2,3,4);
 key3a := Copy(key3,1,2);
 key3b := Copy(key3,3,4);
end;

procedure code;
begin
  form1.memo1.text := StringReplace(form1.memo1.text, 'a','th%6' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'A','th&%6' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'b','g' + key3b + 'fhu' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'B','gf' + key2a + '#hu' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'c','"' + key1a + 'bJs' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'C','"b' + key2a +'%Js' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'd','/' + key2b +'§jT' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'D','' + key3a + '?jT' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'e','&ast' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'E','&a{st' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'f','g@4[' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'F','g' + key2b + '@%4[' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g','JHG³' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'G','JH²³' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'h','&' + key3b +'%gd' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H','&' + key1b + '%%gd' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'i','ß}' + key1a + '=47' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'I','ß' + key3a + '}=G47' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'j','&"' + key3a + '31' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'J','&"}31' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'k','&' + key1b + '%$2' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'K','&%' + key3a + ')$2' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'l','9v' + key1b + '45' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'L','9v' + key2a + '[45' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'm','oed' + key3b + '2' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'M','oe' + key1b + 'dß2' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'n','%' + key2a + '-93' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'N','%-;' + key1a + '93' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'o','jdS' + key2a +'t' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'O','jd' + key1b + '§St' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'p','%h'+ key2a +'te' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'P','%ht' + key2b + '!e' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'q','g' + key1a + 'h92' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'Q','g' + key3a + 'h³92' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'r','th' + key3b + 'vg' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'R','th?' + key3b + 'vg' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 's','}\' + key2a + '23' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'S','}\d' + key1b + '³23' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 't','x' + key2b + 'J%"' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'T','xJ' + key1a + '$%"' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'u','²[' + key3b + 'g]{' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'U','²[g' + key2a + '&]{' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'v','ueb' + key3a + 'A' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'V','' + key2a + 'ebA' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'w','%&5' + key3a + '&' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'W','%&' + key1b + '=5&' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'x','g' + key2b + 'htz' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'X','gh{' + key1b + 'tz' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'y','(th' + key3a + '{G' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'Y','(th!{' + key1a + 'G' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'z','³E' + key2b + '€w' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'Z','³E€@' + key1a + 'w' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, ' ','H$' + key1b + '%³t' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '1','H$' + key1b + '!' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '2','H$' + key1b + '"' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '3','H$' + key1b + '§' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '4','H$' + key1b + '$' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '5','H$' + key1b + '%' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '6','H$' + key1b + '&' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '7','H$' + key1b + '/' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '8','H$' + key1b + '(' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '9','H$' + key1b + ')' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '0','H$' + key1b + '=' , [rfReplaceAll]);
end;

procedure decode;
begin
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '=','0' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + ')','9' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '(','8' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '/','7' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '&','6' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '%','5' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '$','4' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '§','3' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '"','2' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '!','1' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H$' + key1b + '%³t',' ', [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '³E€@' + key1a + 'w','Z' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '³E' + key2b + '€w','z' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '(th!{' + key1a + 'G','Y' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '(th' + key3a + '{G','y' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'gh{' + key1b + 'tz','X' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key2b + 'htz','x' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '%&' + key1b + '=5&','W' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '%&5' + key3a + '&','w' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '' + key2a + 'ebA','V' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'ueb' + key3a + 'A','v' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '²[g' + key2a + '&]{','U' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '²[' + key3b + 'g]{','u' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'xJ' + key1a + '$%"','T' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'x' + key2b + 'J%"','t' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '}\d' + key1b + '³23','S' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '}\' + key2a + '23','s' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'th?' + key3b + 'vg','R' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'th' + key3b + 'vg','r' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key3a + 'h³92','Q' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key1a + 'h92','q' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '%ht' + key2b + '!e','P' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '%h' + key2a + 'te','p' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'jd' + key1b + '§St','O' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'jdS' + key2a +'t','o' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '%-;' + key1a + '93','N' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '%' + key2a + '-93','n' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'oe' + key1b + 'dß2','M' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'oed' + key3b + '2','m' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '9v' + key2a + '[45','L' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '9v' + key1b + '45','l' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&%' + key3a + ')$2','K' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&' + key1b + '%$2','k' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&"}31','J' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&"' + key3a + '31','j' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'ß' + key3a + '}=G47','I' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'ß}' + key1a + '=47','i' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&' + key1b + '%%gd','H' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&' + key3b +'%gd','h' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'JH²³','G' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'JHG³','g' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key2b + '@%4[','F' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g@4[','f' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&a{st','E' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '&ast','e' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '' + key3a + '?jT','D' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '/' + key2b +'§jT','d' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '"b' + key2a +'%Js','C' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, '"' + key1a + 'bJs','c' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'gf' + key2a + '#hu','B' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key3b + 'fhu','b' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'th&%6','A' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'th%6','a' , [rfReplaceAll]);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
     TRY
        Memo1.Lines.Loadfromfile(OpenDialog1.Filename);
     EXCEPT
        ShowMessage ('Fehler beim Laden der Datei!');
     END;
end;



procedure TForm1.Button2Click(Sender: TObject);
begin
  if SaveDialog1.Execute then
     TRY
        Memo1.Lines.SavetoFile(SaveDialog1.Filename);
     EXCEPT
        ShowMessage ('Fehler beim Speichern der Datei!');
     END;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  _var_;
  begin
    if form1.RadioButton1.Checked then
      code;
  end;
  begin
    if form1.RadioButton2.Checked then
      begin;
        code;
        code; //ich weis das es zählschleifen gibt! :-)
      end;
  end;
  begin
    if form1.radiobutton3.checked then
      begin
        code;
        code;
        code;
      end;
  end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  _var_;
  begin
    if form1.RadioButton1.Checked then
      decode;
  end;
  begin
    if form1.RadioButton2.Checked then
      begin;
        decode;
        decode; //ich weis das es zählschleifen gibt! :-)
      end;
  end;
  begin
    if form1.radiobutton3.checked then
      begin
        decode;
        decode;
        decode;
      end;
  end;
end;

end.
so da das ersätzen manchmal schon sehr lange dauert würde ich gern wissen wie ich das hinbeckomme mit disem ladebalcken??

PS: Ist mein programmtext jetzt richtig eingerückt?
Maximilian Ruta
  Mit Zitat antworten Zitat