Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 10.01.09 11:44 
Hi, Delpher,

in einem String sind folgende Einträge gespeichert:

artikel1/3
artikel2/15
artikel3
artikel4/104

Wenn der Artikel nur einmal vorhanden ist, fehlt der Slash.
Wie kann ich den String nach dem Slash elegant in eine (small-) Integer umwandeln?

Danke für Hilfe,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
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: Sa 10.01.09 11:55 
Mit Pos den Slash suchen, dann mit Copy den passenden Teil des Strings ausschneiden, und zuletzt StrToInt.

_________________
We are, we were and will not be.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 10.01.09 12:25 
Danke, Daniel, klappt!
Gruß, Detlef

P.S.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
aktpos := 1; gef := false;
repeat
  if artikel[aktpos] = '/' then gef := true else inc(aktpos);
until gef or (aktpos = length(artikel));  
if gef then
begin
  hstr := copy(artikel, aktpos+1,length(artikel));
  aus_anz := strtoint(hstr);
  showmessage(inttostr(aus_anz));
end;

_________________
ut vires desint, tamen est laudanda voluntas