Autor Beitrag
Robii
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 16.06.09 14:32 
Hey, wie kann ich einen String rückwärts durchgehen, d.h. hinten Anfangen und alles bis zum 1. / in einem neuen String speichern ? Gruß
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 16.06.09 14:35 
ausblenden Delphi-Quelltext
1:
2:
for i := length(myString) downto 1 do
// ...

_________________
We are, we were and will not be.
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 16.06.09 14:45 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
 i: Integer;
 Pla,Dnu: String;
begin
    for i := length(Pla) downto 1 do
      If Pla[i] <> '\' then DNU := DNU+Pla[i];
end;


Das ist mein Code. Aber jetzt habe ich ja die Zeichen im String DNU genau umgekehrt.
Wie ann ich das denn verhindern?
Gruß
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 16.06.09 14:49 
ausblenden Delphi-Quelltext
1:
If Pla[i] <> '\' then DNU := Pla[i] + DNU;					

Kann man drauf kommen, oder?
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Di 16.06.09 15:01 
LastDelimiter existiert... ;)

Damit wird's zum Einzeiler.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 16.06.09 15:06 
Es gibt immer mehrere Wege, aber mir ging es jetzt mehr um das Verständnis ;)
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 16.06.09 15:22 
Stimmt. Peinlich, sorry. Danke nochmal.
Gruß
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 16.06.09 15:30 
Man könnte auch einen StringReplace '\' -> '' versuchen

_________________
PROGRAMMER: A device for converting coffee into software.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Di 16.06.09 15:35 
user profile iconXentar hat folgendes geschrieben Zum zitierten Posting springen:
Man könnte auch einen StringReplace '\' -> '' versuchen

Na, das würde mich aber mal interessieren... :mrgreen:
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 16.06.09 16:16 
Mich auch *g*
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 16.06.09 16:21 
Mich auch, bin für alles, was ich lernen kann dankbar.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 16.06.09 16:29 
Geht es eigentlich um Dateinamen, oder hat der Backslash eine andere Bedeutung? Falls Ersteres, versuch es mal mit ExtractFileName.
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 16.06.09 16:35 
Hab es ja mittlerweile gelöst. Ich wollte den Dateinamen aus einem kompletten Pfad herausfiltern, wobei beides jeweils in Strings abgelegt war. Gruß.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Di 16.06.09 16:37 
user profile iconRobii hat folgendes geschrieben Zum zitierten Posting springen:
Hab es ja mittlerweile gelöst. Ich wollte den Dateinamen aus einem kompletten Pfad herausfiltern, wobei beides jeweils in Strings abgelegt war. Gruß.

Was mal wieder zeigt, dass man ruhig auch mal die eigentliche Problemstellung darlegen darf...
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 16.06.09 16:40 
Na toll, das kommt davon, wenn man nur den Code liest, und nicht die eigentliche Frage :autsch:

Der Code hier
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
 i: Integer;
 Pla,Dnu: String;
begin
    for i := length(Pla) downto 1 do
      If Pla[i] <> '\' then DNU := Pla[i] + DNU;
end;

macht doch im Moment nichts anderes als
ausblenden Delphi-Quelltext
1:
Dnu := StringReplace(Pla, '\''');					

da es keine weitere Abbruchbedingung gibt.
Hab nun aber nachträglich gelesen, dass nur bis zum ersten Vorkommen gearbeitet werden soll - die Abbruchbedingung fehlte im Code, somit ist meine Antwort auch hinfällig *g*

Dafür schmeiß ich nun mal ExtractFileName(); in den Raum

_________________
PROGRAMMER: A device for converting coffee into software.
Robii Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236



BeitragVerfasst: Di 16.06.09 17:23 
Auch die Abbruch Bedinung habe ich schon selbst hinugefügt. Einfach

ausblenden Delphi-Quelltext
1:
If Pla[i] = '\' then break;					


Und schon bin ich am Ziel.
Gruß.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 16.06.09 17:59 
ExtractFileName hatten wir schon :P