Autor Beitrag
LonghornUser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 11.03.07 23:01 
Hallo,

ich habe hier ein Memo und darin Benutzerdaten, also in etwa so:
ausblenden Quelltext
1:
2:
3:
4:
Name: xxx
Vorname: yyy
Straße: zzz
...

Jetzt möchte ich aus dem Text die Werte hier xxx, yyy und zzz auslesen, also ab einem bestimmten Schlüsselwort bis zu einem Zeilenumbruch.

Wie mache ich das am besten ?

Danke schonmal.

Ciao LHUser


Moderiert von user profile iconChristian S.: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 11.03.2007 um 22:04
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 11.03.07 23:05 
Die einzelnen Zeilen des Memos mittels memo1.Lines[i] ansprechen. Dann mittels Pos oder über die Länge des Textes vor dem Doppelpunkt (ist ja bekannt) die Startposition bestimmen. Mit der dann einfach per Copy den Text rausholen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mo 12.03.07 00:00 
Dankesehr. Funktioniert nun super.
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Fr 16.03.07 13:08 
habe fast dasselbe Problem

ich möchte den namen, der in oldfile hinterlegt ist ab der 17. Stelle von Rechts kopieren

bei der volgenden Zeile sagt er mir drei mal 'Inkompatible Typen' und nichts mehr
ausblenden Delphi-Quelltext
1:
newfile := copy(oldfile,pos(length(oldfile)-17),pos(length(oldfile)-17));					


kann mir bitte da jemand weiter helfen?
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Fr 16.03.07 13:21 
Hallo!

Dein Fehler liegt bei dem pos

Hilfe:

Delphi-Syntax:
ausblenden Delphi-Quelltext
1:
function Pos(Substr: string; S: string): Integer;					


Beschreibung

ausblenden Quelltext
1:
2:
3:
In Delphi sucht Pos in dem String S nach dem Teil-String Substr. Die Parameter Substr und S sind String-Ausdrücke.

Wird der Teil-String gefunden, gibt Pos den Integer-Index des ersten Zeichens von Substr in S zurück. Die Groß/Kleinschreibung wird von Pos nicht berücksichtigt. Ist Substr nicht vorhanden, wird der Wert Null zurückgegeben.


also

ausblenden Delphi-Quelltext
1:
 newfile:= copy(oldfile, length(oldfile)-17, length(oldfile)-17);					


LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Lucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

XP
Delphi 7
BeitragVerfasst: Fr 16.03.07 13:27 
mache am besten zuerst das pos seperat u. dann das copy
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Fr 16.03.07 13:30 
Er braucht das POS doch gar nicht machen!

Er weiß doch, das er ab der 17. Stelle von rechts anfangen will zu kopieren!

Pos() machst du nur wenn du ein Zeichen suchst und die Position auf das erste Vorkommen desselbigen.

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Fr 16.03.07 13:33 
hmm..

nach dem ich es gepostet habe, ist es mir auch eingefallen, habe das genau so wie du gemacht, doch er sagt immer noch drei mal 'Inkompatible Typen'

jetzt sieht mein Code so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
 for i := 0 to index.Count - 1 do
  begin
    oldfile.Add(ExtractFileName(lsb_files.Items[i]));
    textpos := length(oldfile)#-17;
    newfile:= copy(oldfile,# textpos, textpos);
    edit1.Text := string(newfile);
  end;


separat will er das auch nicht

bei # setzt er den Mauszeiger wenn ich auch die Fehlermeldungen 'Inkompatible Typer' klicke.
Lucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

XP
Delphi 7
BeitragVerfasst: Fr 16.03.07 13:35 
ja stimmt hab da grad was falsch aufgefasst sorry
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Fr 16.03.07 13:35 
was solln das # bedeuten??

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Fr 16.03.07 13:53 
user profile iconZeitGeist87 hat folgendes geschrieben:
was solln das # bedeuten??


da setzt er mir den Cursor wenn ich auf die Fehlermeldungen klicke.
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Fr 16.03.07 13:58 
Von welchem Typ sind Textpos und newfile?


Textpos muss Integer sein, newfile ein String.

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 16.03.07 14:11 
Was soll das sein ?
ausblenden Delphi-Quelltext
1:
edit1.Text := string(newfile);					



ausblenden Delphi-Quelltext
1:
edit1.Text := newfile;					

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Fr 16.03.07 14:24 
user profile iconZeitGeist87 hat folgendes geschrieben:
Von welchem Typ sind Textpos und newfile?


Textpos muss Integer sein, newfile ein String.

LG
Stefan


Textpos ist integer und newfile ist string


user profile iconBlackheart666 hat folgendes geschrieben:
Was soll das sein ?
ausblenden Delphi-Quelltext
1:
edit1.Text := string(newfile);					



ausblenden Delphi-Quelltext
1:
edit1.Text := newfile;					


bei edit1.Text := newfile; sagt er mir 'Inkompatible Typen 'string' und 'TStringList'!!
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Fr 16.03.07 14:26 
dann ist der fehler klar :)

TStringList ist eine Liste von Strings!
Versuch mal ne Liste in ein Eingabefeld zu bekommen :)

was aber geht:

ausblenden Delphi-Quelltext
1:
 edit1.text:= newfile.strings[n];					


wobei n für einen Index in deiner Liste steht.

Beachte:
Index geht bei 0 los und hört bei count-1 auf!

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Fr 16.03.07 14:32 
user profile iconZeitGeist87 hat folgendes geschrieben:
dann ist der fehler klar :)

TStringList ist eine Liste von Strings!
Versuch mal ne Liste in ein Eingabefeld zu bekommen :)

was aber geht:

ausblenden Delphi-Quelltext
1:
 edit1.text:= newfile.strings[n];					


wobei n für einen Index in deiner Liste steht.

Beachte:
Index geht bei 0 los und hört bei count-1 auf!

LG
Stefan


das ist ja kein Problem, das Problem ist, dass er mir die letzten 17 Zeichen aus einem String nicht kopieren will!!

ausblenden Delphi-Quelltext
1:
2:
3:
oldfile.Add(ExtractFileName(lsb_files.Items[i]));
    textpos := length(oldfile.)-17;
    newfile:= copy(oldfile, textpos, textpos);
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Fr 16.03.07 14:35 
ausblenden Delphi-Quelltext
1:
2:
3:
 oldfile.Add(ExtractFileName(lsb_files.Items[i]));
 textpos := length(oldfile.)-17;
 newfile:= copy(oldfile.strings[oldfile.count-1], textpos, textpos);


Musst ihm schon sagen welche Zeile.
Ich hab jetzt einfach die letzte genommen, weils am logischstem ist.

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.


Zuletzt bearbeitet von ZeitGeist87 am Fr 16.03.07 14:36, insgesamt 2-mal bearbeitet
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 16.03.07 14:35 
War jetzt Quatsch. Sorry

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)