Autor Beitrag
Sauger Chris
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Mo 12.05.08 12:03 
moin
und zwar versuche ich gerade einen string mit copy und pos zu bearbeiten

aber irgend wie will das noch nicht so wie ich :)

hier mal mein source

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Button1Click(Sender: TObject);
var i,
    Position1,
    Position2    : integer;
    checkstring  : string;
begin
for i:=0 to memo1.Lines.count -1 do
begin
checkstring := memo1.Lines.Strings[i];
position1 := Pos('CREATE TABLE `',memo1.Lines[i]);               // start position suchen
position2 := Pos('` (',memo1.Lines[i]);                          // end position ermitteln
memo2.Lines.Add((Copy(checkstring, Position1+14, position2)));   //hier wird wohl der fehler sein

end;end;


es soll der string zwischen CREATE TABLE ` und ` ( aus gegeben werden

beispiel
CREATE TABLE `fusion_admin` ( ---> fusion_admin
CREATE TABLE `fusion_articles` ( ---> fusion_articles
CREATE TABLE `fusion_article_cats` ( ---> fusion_article_cats

ps. wolte das so machen er sucht nach CREATE TABLE ` so hat er schon mal die erste position
und mit position2 wolte ich das ende ermitteln also ` (

was is da blos falsch


thx für eure hilfe
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: Mo 12.05.08 12:15 
Hallo,

das letzte Argument von Copy ist mit "Count" bezeichnet. :wink:

Du verwendest eher "Kopiere bis Eintrag", Du musst die Länge zwischen Position 1 und 2 berücksichtigen.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )