hallo Community,
Ich hab ein sehr seltsames Phenomen, vielleicht weiß jemand von euch Rat.
Ich versuche mich an einem Dateiparser, und im folgenden Seht ihr den Code für meine Wort-Parse Routine. isSeparator prüft ob das eingelesene Zeichen ein lf, cr, tab, komma oder space ist.
Das geht ne ganze weile gut, aber dann komm ich an eine stelle an der ich den string "1.75" vom stream lesen will. bis "1." klappt es, und beim versuch die "7" an den string zu hängen
Delphi-Quelltext
kachelt es

Kann sich jemand darauf einen reim machen?
Danke schonmal,
Peter
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38:
| function nextWord(aStream : TStream; moveOn : boolean = true) : string; var c : Char; savePos, savePos2 : integer; finish : boolean; s : string; begin result := ''; setlength(result, 0); if not moveOn then savePos := aStream.Position; finish := false; while (length(result) = 0) or not finish do begin aStream.Read(c,1); finish := false; if c = '#' then begin readLn(aStream, s); finish := true; end; if isSeparator(c) then finish := true; if not finish then begin result := result + c; end; if (result = '{') or (result = '}') or (result = '[') or (result = ']') then finish := true; savePos2 := aStream.Position; aStream.Read(c,1); if (c = '}') or (c = ']') then finish := true; aStream.Position := savePos2; end; if not moveOn then aStream.Position := savePos; end; |