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

Bug in function ppCapitalize ?

edited June 2003 in General
Sounds like a bug in function ppCapitalize.
When running Capitalize on a string that ends with a space, an exception is
raised. To get around the following line should be added in the loop.
Actually it sounds like this is what the developer intended with checking
for liPos < liLength in the while statement, but without resetting liLength
it doesn't help anything.

{ppUtils.pas line 3747}
liLength := Length(lsWord);

Please correct me if I'm wrong.

-Jack

Comments

  • edited June 2003
    Jack,

    Which version of ReportBuilder are you using? PpCapitalize was updated in
    ReportBuilder 7.02 and does not have this issue any longer.

    --
    Best Regards,

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

    The following is a snip of the ppCapitalize function in 7.02. run the
    following test in a simple program.

    function ppCapitalize(const aString: String): String;
    var
    liPos: Integer;
    liLength: Integer;
    lsWord: String;
    begin

    Result := aString;

    liLength := Length(Result);

    if (liLength = 0) then Exit;

    Result := LowerCase(Result);

    Result[1] := UpperCase(Result[1])[1];

    lsWord := Result;

    liPos := Pos(#32, lsWord);

    while (liPos <> 0) and (liPos < liLength) do
    begin
    lsWord[liPos + 1] := UpperCase(lsWord[liPos + 1])[1];

    lsWord := Copy(lsWord, liPos + 1, Length(lsWord));

    Result := Copy(Result, 1, Length(Result) - Length(lsWord)) + lsWord;

    liPos := Pos(#32, lsWord);
    end;

    liPos := Pos('_', lsWord);

    while (liPos <> 0) and (liPos < liLength) do
    begin
    lsWord[liPos + 1] := UpperCase(lsWord[liPos + 1])[1];

    lsWord := Copy(lsWord, liPos + 1, Length(lsWord));

    Result := Copy(Result, 1, Length(Result) - Length(lsWord)) + lsWord;

    liPos := Pos('_', lsWord);
    end;

    end; {function, ppCapitalize}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ShowMessage(ppCapitalize('My Address '));
    end;

  • edited June 2003
    Hi Jack,


    which runs fine, I can't reproduce your problem.

    regards,
    Chris Ueberall;
  • edited June 2003
    Hi Chris,

    Have you tried the ShowMessage I posted, with the space at the end?
    When I run it I get "Check Range Error".

    -Jack

  • edited June 2003
    Hi Jack,

    I tried running your code as well and was unable to recreate the error. I
    ran a diff on the ppCapitalize code you sent and the code I use and they
    seemed to be identical. Please send a small running example that re-creates
    the error to support@digital-metaphors.com and I will research this further.

    --
    Best Regards,

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

    When I create a project add a Report, drop a ppVariable and assign in OnCalc
    Value := ppCapitalize('My Address '); all works fine. But if I add
    RBuilder\Source to the search path, I get Range Check Error.

    Could there be something wrong with my installation, or the way my ppUtils
    was recompiled?

    -Jack

  • edited June 2003
    Hi Jack,

    I tried what you described below and could produce no error. This could be
    caused by an error in your installation. Please verify that the date on
    your current ppUtils.pas file is 03/06/19 1:25pm. Feel free to send an
    e-mail to support@digital-metaphors.com requesting this file and I'll send
    it right out to you.

    --
    Best Regards,

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