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

Reversing Sign

edited August 2005 in RAP
I want to reverse the sign on some numbers, printing them as a negative
instead of a positive. So, I put the following code in an OnGetText event.

Text:=CurrToStr(-StrToCurr(Text));

It compiles fine, but when I go to run the report, it tells me: "Could not
run program: DBText20OnGetText" which is referring to the component where I
have inserted this code above. I also have tried rewriting the code to use
a variable and do three steps to get the same result. The error message is
the same. Can anyone explain why I get this error message when the RAP code
compiles with no errors?

The variable is a currency variable, but the OnGetText defines the Text as a
string, so I am assuming that I must convert Text to currency and back
again. I tried doing Text:='-'+Text, but this shows a negative before
numbers that are 0.00, which is not desirable.

David Miller.

Comments

  • edited August 2005
    HI David,

    The following RAP code worked for me. The StrToCurr is simply a pass thru
    function to the Delphi StrToCurr method.

    lTemp := StrToCurr('-' + Text);
    Text := CurrToStr(lTemp);

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2005
    What kind of variable are you declaring lTemp as? I tried the following
    code:

    var
    c1 : currency;
    begin
    c1:=StrToCurr('-'+Text);
    Text:=CurrToStr(c1);
    end;

    It still gives me the same error message. Again, the code compiles with no
    errors, but when the report is previewed on the screen, I get "Could not run
    program: DBText20OnGetText"

    David Miller


  • edited August 2005
    Never mind, Nico. I figured out what it was. In the Text variable was a
    currency symbol ($), which was causing the StrToCurr function to raise an
    exception. Thanks for your help.

    David Miller

This discussion has been closed.