Autor Beitrag
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Mo 06.03.06 14:20 
Hallo, habe folgenden Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TUpdate_Prog.Button6Click(Sender: TObject);
var
a, check:integer;
pfad, ex_datei : string;
begin
 ex_datei := '\\w3m008\thorsten\test';
 check := 0;
 for a := 0 to length(ex_datei)-1 do
 begin
    pfad := pfad + ex_datei[a];
    if pfad = '\' then
        inc(check);
    if check = 3 then
        break;
 end;
end;


Wenn ich diesen Code ausführe sollte doch in der pfad Variablen \\w3m008\ stehen, tut es aber nicht es steht alles von ex_datei drin.
Wie kann ich also den Backslash abfragen?

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Bronstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Mo 06.03.06 14:27 
Hat sich erledigt habe die falsche variable genommen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
a, check:integer;
pfad, ex_datei : string;
begin
 ex_datei := '\\w3m008\thorsten\test';
 check := 0;
 a:=length(ex_datei);
 for a := 1 to length(ex_datei)-1 do
 begin
    pfad := pfad + ex_datei[a];
    if ex_datei[a] = '\' then
        inc(check);
    if check = 4 then
        break;
 end;

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 06.03.06 18:49 
Guck dir mal Suche in der Entwickler-Ecke COPY(); und Suche in der Entwickler-Ecke POS(); an. Das sollte das sein, was du brauchst.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Di 07.03.06 00:16 
Hallo,

mit Copy ja, aber Pos?, da gefällt mir der Ansatz von user profile iconBronstein besser.
Das in eine Funktion verpackt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
function CopyPosX(s: String;Delimiter: Char;Count: Integer): String;
var z,i,L : Integer;
begin
  i := 0;
  z := 0;
  L := Length(s);
  while (i < count) and (z < L) do
    begin
    inc(z);
    if s[z] = Delimiter then
      inc(i)
    end;
  Result := Copy(s,1,z);
end;
//...
showmessage(CopyPosX('\\w3m008\thorsten\test','\',3));

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 07.03.06 06:49 
Pos(); würde auch gehen, in dem er die ersten 2 Leerzeichen erstmal abschneidet
ausblenden Delphi-Quelltext
1:
2:
MyInteger := Pos('\', Copy(MyString, 3, Length(MyString) - 2);
MyString2 := Copy(MyString, MyInteger + 2, Length(MyString) - MyInteger + 2);

(ungetestet)

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)