Es hängt davon ab, wie das Feld tatsächlich in Paradox deklariert wird. Wenn es ein TMemoField ist, ist es ziemlich einfach:
var
SL: TStringList;
Line: string;
begin
SL := TStringList.Create;
try
SL.Text := YourMemoField.GetAsString;
for Line in SL do
// Process each line of text using `Line`
finally
SL.Free;
end;
end;
Wenn es ein TBlobField ist, ist es ein wenig komplizierter. Sie müssen das Memo-Feld mit einem TBlobStream
, und laden Sie den Inhalt dieses Stroms in einen TStringList
lesen:
// For Delphi versions that support it:
procedure LoadBlobToStringList(const DS: TDataSet; const FieldName: string;
const SL: TStringList);
var
Stream: TStream;
begin
Assert(Assigned(SL), 'Create the stringlist for LoadBlobToStringList!');
SL.Clear;
Stream := DS.CreateBlobStream(DS.FieldByName(FieldName), bmRead);
try
SL.LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
// For older Delphi versions that do not have TDataSet.CreateBlobStream
procedure LoadBlobToStringList(const DS: TDataSet; const TheField: TField;
const SL: TStringList);
var
BlobStr: TBlobStream;
begin
Assert(Assigned(SL), 'Create the stringlist for LoadBlobToStringList!');
SL.Clear;
BlobStr := TBlobStream.Create(DS.FieldByName(TheField), bmRead);
try
SL.LoadFromStream(BlobStr);
finally
BlobStr.Free;
end;
end;
// Use it
var
SL: TStringList;
Line: string;
begin
SL := TStringList.Create;
LoadBlobToStringList(YourTable, YourMemoFieldName, SL);
for Line in SL do
// Process each Line, which will be the individual line in the blob field
// Alternatively, for earlier Delphi versions that don't support for..in
// declare an integer variable `i`
for i := 0 to SL.Count - 1 do
begin
Line := SL[i];
// process line of text using Line
end;
end;
'TStringList' unterstützt Parsing Text, '# 13 # 10' verwenden,' # 13' und ' # 10' als Zeilenumbrüche. –
@Remy Documentation states "Beim Festlegen von Text wird der Wert analysiert, indem bei jedem Wagenrücklauf oder Zeilenvorschub in Teilzeichenfolgen getrennt wird. (Die beiden müssen keine Paare bilden.)" Ist das veraltet? Ich habe die Dokumentation genau zu diesem Punkt überprüft, kurz vor meiner letzten Bearbeitungsfrist (d. H. Dem letzten Satz). –
nein, es ist immer noch gültig. Wenn die 'LineBreak' -Eigenschaft auf' sLineBreak' (der systemeigene Zeilenumbruch) gesetzt ist, werden alle drei Zeilenumbruchtypen ('CR',' LF', 'CRLF') gesucht. Wenn die Eigenschaft 'LineBreak' auf etwas anderes gesetzt ist, wird nur nach diesem Wert gesucht. –