Re: data from text extractionPosted by WAllison on December 06, 2001: In Reply to: Re: data from text extraction posted by WAllison on December 06, 2001: : : I've got a question..: : : how can i extract certain values (int's or string's) from a text file?? : : it's like this: : //no frills - dunno how reliable this one is - but it gives u an idea of how to approach the problem:... .... ----------
function TMainForm.GetDataStrings2(FileName: string; DataList: TStringList): boolean; var F: TextFile; s: string; APos, BPos: integer; begin AssignFile(F, FileName); Reset(F); While not EOF(F) do begin ReadLn(F, s); If s[Length(s)] <> ',' Then s := s + ','; APos := Pos('=', s); If APos > 0 Then begin While (s[APos] <> ' ') do APos := APos - 1; APos := APos + 1; s := Copy(s, APos, Length(s)); While Length(s) > 0 do begin BPos := Pos(',', s); DataList.Add(Copy(s, 0, BPos - 1)); Delete(s, 1, BPos + 1); end; end; end; CloseFile(F); Result := DataList.Count > 0; end; |