Home General

Memo clearing routine NOW seems to have a bug in it

Using Delphi 7 with freshly installed RB 19.02 Build 243. First time. I compiled a program after making a few cosmetic changes. I tested it with a label. Everything worked. Off to production. Production sent me back a report that showed that after the first label, the second label would have two lines of description rather than one. The third had three. And so on and so on. Eeek!

What I discovered was that the description ppmemo wasn't clearing between records. I used ppmemo.clear, as I have done through history. It's a simple routine that searches the catalog of parts for an Extended Description, which is a memo field. If that's empty, it reverts to using the standard description, a limited-length string field. The routine is in the standard library for me. And now, I fear compiling ANY of my programs, especially the BIG ones, will goof things up. Do I have to change all ppmemo.clear to ppmemo.lines.clear? And why?

Here's the code:
procedure TFrmMain.FillOutExtendedDescription;
var
  XDesc : string;
begin
  XDesc := getS(TblCat,'ExtendedDesc'); // memo field
  if XDesc = '' then XDesc := getS(TblCat,'Description'); // std string field
  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  // TODO 3 -cBug -oGary: I had to change this to .lines.clear from .clear. Why? Needs investigating
  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  // zebraPartDescLong.Clear; // empty pp memo field
  zebraPartDescLong.Lines.Clear; // empty pp memo field
  zebraPartDescLong.Lines.Add(XDesc);  // add whatever description I found
end;
Thanks, GM

Comments

  • Hi Gary,

    I am unsure how this worked in previous versions of ReportBuilder. I checked our source back to RB 7 and the Clear routine hasn't ever been implemented in the TppMemo class. It is implemented in the ancestor TppPrintable and sibling TppDBMemo but has not in any way cleared the memo content.

    I'm sorry but it appears that you will need to update your code to call Lines.Clear to get the effect you are after. Or, for an even better solution, simply update the Lines.Text property rather than clearing and adding. Performing a find in files operation in Delphi should make the update fairly simple.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Nico,

    This has worked for a loooooong time. No doubling up on the extended description from one print session to another within running the program. BUT, I've discovered that the reason it MIGHT have hidden away is that each print session for my main programs goes out to a form, where choices are made and information filled in, then comes back after printing. I've escaped the issue because few people ever stayed within that one print session and then printed multiple things.

    Obviously, it would have been better if ppmemo1.clear; would generate a warning or even better, an error. But it is what it is. As you say, A search through the various units that have print in the name and have a .clear in them is underway. I'll be finished tonight. So, other than some agita, no harm, no foul.

    Part of that learning curve I will always see stretching out to the horizon. Thanks. GM
Sign In or Register to comment.