Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

Convert Binary Template to Text

edited February 2004 in End User
Sirs

I am moving databases and have followed your example project for converting
Binary data into ASCII for editing for the new database. The sample you
give with the project works fine.

When I get to the ObjectBinaryToText(lFileStream, lTextStream); line
in my code, I consistently get and E.Read Error when trying to read the
binary data below.

The error always occurs about the Default Printer text.

Any advice as to why would be greatfully appreciated.

Regards

Philip L Jackson

Env. Delphi6 ENT, Report Builder 6.03 Ent Win XP Pro.

Code sample below :-

lsFileName: String;
lFileStream: TFileStream;
lTextStream: TMemoryStream;
begin
Richedit1.Clear;
Richedit1.PlainText := TRUE;

with wwDBRichEdit1 do
begin
lsFileName := 'c:\reports\test4.rtm';
PlainText := True;
selectAll;
Lines.SaveToFile(lsFileName);
lFileStream := TFileStream.Create(lsFileName, fmOpenRead);
lTextStream := TMemoryStream.Create;

try
lFileStream.Position := 0;
ObjectBinaryToText(lFileStream, lTextStream);
lTextStream.Position := 0;
Richedit1.Lines.LoadFromStream(lTextStream);
Richedit1.Lines.SaveToFile('c:\reports\ads test3.rtm');
finally
lFileStream.Free;
lTextStream.Free;
end;
end;// end of with DBRichEdit1 do





Data Sample

TPF0 TppReport ppReport1AutoStopDataPipeline
plJobsheetPrinterSetup.BinNameDefaultPrinterSetup.DocumentNameReportP
rinterSetup.PaperNameA4 210 x 297
mmPrinterSetup.PrinterNameDefaultPrinterSetup.mmMarginBottom?PrinterS
etup.mmMarginLeft?PrinterSetup.mmMarginRight?PrinterSetup.mmMarginTop
?PrinterSetup.mmPaperHeightY?e

Font.Style
fsBoldfsItalicJOBNODataPipeline
plJobsheetFont.CharsetDEFAULT_CHARSET
Font.ColorclBlack Font.NameARIAL Font.Size
Font.Style
ht,.mmPrintPositioname
"Jobsheet.DB"sheet
TableSQLAliasJobsheet
"Contract.DB"
TableAliasContract
TableSQLAliasContract

Comments

  • edited February 2004
    Hi Philip,

    Try adding the following code just under your call to ObjectTextToBinary.
    You will need to declair and create a local TWriter object giving the new
    TWriter your result stream.

    lWriter.Root := nil;
    lWriter.WriteListEnd;

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2004
    Thanks will try but as far as I can see the exception occurs on the
    ObjectTextToBinary command.

    Regards


  • edited February 2004
    Hi Philip,

    In addition, you might check that you have the proper read/write permissions
    set on your file streams when you create them. If you have you destination
    stream set to just read (fmOpenWrite) you may also get a read error.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.