Just to compare results, I also called SaveTextW. This writes the correct string to the file.
The function I am using is below. The RVE1 component is TRichViewEdit.
Am I doing something wrong here?
Thanks
Mike Simmons
Code: Select all
FUNCTION TFindGeneration.GetKPADesc(seq: INTEGER): STRING;
var
S: string;
TempStream: TRVMemoryStream;
BEGIN
Result := '';
s := '';
RVE1.Clear;
IF NOT IBQuery2.active THEN
Exit;
TempStream := TRVMemoryStream.Create;
Try
IF IBQuery2.Locate('id_sequence', VarArrayOf([seq]), []) THEN
BEGIN
IF not IBQuery2.FieldByName('AbbrevText').IsNULL
THEN BEGIN
IBQuery2AbbrevText.SaveToStream(TempStream);
END
ELSE BEGIN
IBQuery2Text.SaveToStream(TempStream);
END;
TempStream.Position := 0; // reset to the beginning of the stream
RVE1.LoadFromStream( TempStream, rvynaAuto );
RVE1.Format;
RVE1.SaveTextW('c:\temp\texttest.txt', 0);
TempStream.Clear;
RVE1.SaveTextToStreamW('', TempStream, 0, false, True);
TempStream.Position := 0;
SetString(s,PChar(TempStream.memory),TempStream.Size);
S := StringReplace(S, #13, '', [rfReplaceAll]);
S := StringReplace(S, #10, '', [rfReplaceAll]);
Result := S;
END;
Finally
TempStream.Free;
End;
END;