Autor Beitrag
th3Thr1ll3r
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 31

Win XP Prof
Delphi 6 Pers.
BeitragVerfasst: Mo 09.10.06 18:24 
hallo, ich habe ein Frage:

wie kann ich eine Funktion auf jedes Zeichen in meinem Text anwenden? Nacheinander versteht sich ;)

MfG

thriller
rizla
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 417
Erhaltene Danke: 2

XP
FPC mit Lazarus
BeitragVerfasst: Mo 09.10.06 18:26 
In welchem Text? Ists ein Memo?
Verrat mal mehr..

:r!a:

_________________
if you have what they want - they'll find a way to take it (bruce sterling)
WOW - 10 JAHRE Mitglied beim Delphi-Forum. Wie die Zeit vergeht, Freunde.
th3Thr1ll3r Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 31

Win XP Prof
Delphi 6 Pers.
BeitragVerfasst: Mo 09.10.06 18:40 
Ja, in diesem Fall ist es n Memo.

Möchte einen Text in Dualzahlen übersetzen, die funktionen "char2ascii" und "ascii2duals" hab ich mir gemacht, und jetzt will ich halt wissen, wie ich diese Funktionen auf jeden Buchstaben im Text anwenden kann.

MfG

thriller
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 09.10.06 18:48 
user profile iconrizla hat folgendes geschrieben:
In welchem Text? Ists ein Memo?
Verrat mal mehr..

Is doch eigentlich total egal...

Du kannst mit [i] hinter dem String auf den i-ten Buchstaben zugreifen. Egal ob das Memo1.Text ist oder ein anderer String.
Beispiel:
ausblenden Delphi-Quelltext
1:
ShowMessage(Memo1.Text[i]);					

Und SHowMessage wird ja auf jeden einzelnen Char angewendet. Wenn du das, wie ich das verstandan habe, auch umgewandelt zurückspeichern willst, dann musst du halt Memo1.Text vorher in ne Variable speichern und dann die durchlaufen.
azubi_20
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 593

WinXP SP2, Ubuntu 8.4
D7 Enterp., D2005 Prof., Java (Eclipse 3.4.0)
BeitragVerfasst: Mo 09.10.06 18:53 
nehmen wir mal an dein text ist ein String. dann kannst du auf ein einzelnes Zeichen über seinen Index zugreifen. Um auf alle Zeichen zuzugreifen, packst du das ganze in eine schleife die bis zum Ende des Strings durchgeht. Auf die einzelnen Zeilen deines Memos greifst du auch über den Index zu. Das kann dann so aussehen :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var i : integer;
   deintext : string;

i := 0;//Index des Zeichens
j := 0;//Index der Zeile
repeat
  repeat
    deineFunktion(memo.lines[j][i]);
    i:=i+1; 
  until i > memo.lines[j].length;
  j:=j+1;
until j > memo.lines.count;


Zuletzt bearbeitet von azubi_20 am Mo 09.10.06 18:54, insgesamt 1-mal bearbeitet
rizla
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 417
Erhaltene Danke: 2

XP
FPC mit Lazarus
BeitragVerfasst: Mo 09.10.06 18:53 
user profile iconjaenicke hat folgendes geschrieben:
user profile iconrizla hat folgendes geschrieben:
In welchem Text? Ists ein Memo?
Verrat mal mehr..

Is doch eigentlich total egal...

So egal ist das NICHT, denn ich muss, wenn ich für den kollegen code poste, schon wissen, ob ich .lines[] oder .items[] nehmen muss.. :flehan:

_________________
if you have what they want - they'll find a way to take it (bruce sterling)
WOW - 10 JAHRE Mitglied beim Delphi-Forum. Wie die Zeit vergeht, Freunde.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 09.10.06 18:59 
Na ja, wenn du natürlich den Code so schreiben willst, klar. Deshalb hab ichs halt allgemein auf nen String bezogen ;-).
rizla
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 417
Erhaltene Danke: 2

XP
FPC mit Lazarus
BeitragVerfasst: Di 10.10.06 16:46 
so allgemein hast DU natürlich recht ;)

regards
:r:

_________________
if you have what they want - they'll find a way to take it (bruce sterling)
WOW - 10 JAHRE Mitglied beim Delphi-Forum. Wie die Zeit vergeht, Freunde.