Autor Beitrag
Xearox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260
Erhaltene Danke: 3



BeitragVerfasst: Mo 01.02.10 12:57 
Hallo Leute

ich bins mal wieder...

ich habe eine Frage...ich möchte gerne aus mehreren wörtern die einzelnen Buchstaben extraieren und denen Werte geben...


ich denke, das man das mit einer IF THEN bedingung machen kann.

aber ich habe keine AHnung...kann mir jemand helfen???

Beispiel:

A -B -C -D -E -F -G -H -I -J -K -L -M -N -O -P -Q -R -S -T -U -V -W -X -Y -Z
00-01-02-03-04-05-06-07-08-09-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25

das sind die werte...

und nun das wort

HALLO
0700111114

wie bekomme ich nun hin, dass wort genau so auseinander genommen wird, und diese werte hinzugefügt werden?
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Mo 01.02.10 13:00 
das ginge, indem du den ASCII-Wert jedes Buchstaben in einem String hernimmst und dann ord('A') abziehst. Um die 0 vor der Zahl kann man sich dann ja immernoch kümmern.
Xearox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260
Erhaltene Danke: 3



BeitragVerfasst: Mo 01.02.10 13:05 
kannst du eventuell ein kleines Beispielt geben, weiß nicht so recht, wie ich das einbringen kann...
martin300
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 186
Erhaltene Danke: 2



BeitragVerfasst: Mo 01.02.10 16:21 
Hi,
da gibt es sehr viele Möglichkeiten wie sich das realisieren lässt. Folgendes Beispiel verwendet 2x TStringList. Verschlüsseln funktioniert, für das Entschlüsseln muss nur die EncodeList verwendet werden.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
procedure TForm1.Button1Click(Sender: TObject);
var
  DecodeList, EncodeList : TStringList;
  StrToDecode, singleChar : string;
  I: Integer;
  CharPosition : Integer;
  ResultString : String;
begin
  DecodeList := TStringList.Create;
  EncodeList := TStringList.Create;

  // Beide Listen gehören zusammen umd müssen immer
  // gemeinsam geändert werden.
  DecodeList.CommaText := 'A=00, B=01, C=02';
  EncodeList.CommaText := '00=A, 01=B, 02=C';

  // Text der verschlüsselt wird
  StrToDecode := 'BAC';

  // Verschlüsseln
  for I := 1 to length(StrtoDecode) do
  begin
     singleChar := StrToDecode[i];
     CharPosition := DecodeList.IndexOfName(singleChar);
     if CharPosition <> -1 then
     begin
        ResultString := ResultSTring +' '+DecodeList.ValueFromIndex[CharPosition];
     end else
     begin
       ResultString := ResultString + ' ?';
     end;
  end;

  // Ausgabe
  showmessage (ResultString);

  DecodeList.Free;
  EncodeList.Free;
end;
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Mo 01.02.10 22:02 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
function strToNums(s:String) : String;
var
  i : integer;
  str : string;
begin
  str := ''

  result := '';
  if length(s) = 0 then exit;

  for i := 1 to length(s) do
    str := str + intToStr(ord(s[i])-ord('A'))

  result := str;

end;