Autor Beitrag
Roadrunner116
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 89

Win XP Home, Ubuntu Linux 6.06
Delphi 7, Java, PHP
BeitragVerfasst: Do 25.01.07 22:35 
Hallo, ich habe eine eigene procedure erstellt.

www.delphi-forum.de/...69033&highlight=

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.verSchluessel(text: string); 
begin
  text := StringReplace(text, 'A', '#1F', [rfReplaceAll, rfIgnoreCase]);
...
  text := StringReplace(text, 'F', '#32', [rfReplaceAll, rfIgnoreCase]);
...
...
  Memo_Output.Text := text;
end;


so! Ich habe jedem Zeichen, dass ich ersetzen will eine eigene Hexadezimalzahl zugedacht und lasse dieses Zeichen in diese ersetzen.
Jetz das Problem!

Wenn ich A zum Beispiel in #1F umwandle ist alles ok!
Wenn ich F zum Beispiel in #32 umwandle wandelt diese procedure auch das "F" aus meinem bereits ersetzten A (#1F) um.
Wie kann man das verhindern?

Gruß Roadrunner116
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 25.01.07 22:48 
Moin!

user profile iconRoadrunner116 hat folgendes geschrieben:
Wenn ich A zum Beispiel in #1F umwandle ist alles ok!
Wenn ich F zum Beispiel in #32 umwandle wandelt diese procedure auch das "F" aus meinem bereits ersetzten A (#1F) um.
Wie kann man das verhindern?

Mit StringReplace() lässt sich das nicht verhindern. :| ;)

Ansatz: ;)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
const
  Codes: array['A'..'Z'] of String = (
    '#12',  // =A
    '#23',  // =B
    ...
    '#FF'); // =Z

var
  i: Integer;
  Klartext, Codiert: String;

begin
  Klartext := 'HALLO TEST';
  Codiert := '';
  for i := 1 to Length(Klartext) do
    Codiert := Codiert +Codes[Klartext[i]];

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Roadrunner116 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 89

Win XP Home, Ubuntu Linux 6.06
Delphi 7, Java, PHP
BeitragVerfasst: Do 25.01.07 22:56 
schade...
naja ich probier mal ein wenig damit herum...
Dank dir