IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#20821 - 11/02/07 03:00 PM Addition in a Local Variable
TanyaD Offline
OL User

Registered: 06/15/04
Posts: 55
Loc: Texas
I have this expression in a Local Variable:
=Trim(Trim(@FormatAmountStr(@(1,510,523),',')))+Trim(Trim(@FormatAmountStr(@(1,524,537),',')))

I am only getting the two amounts side by side, it is not adding them. Is there some way I can get the two to add together?
_________________________
Tanya D

Top
#20822 - 11/02/07 07:27 PM Re: Addition in a Local Variable
Phree Offline
OL Expert

Registered: 09/26/02
Posts: 465
Loc: South Coast, UK
Hi Tanya,

I had an old PP3 form that I needed to add some numbers up. I've just loaded it into PP5 and it still works perfectly. It's a little piece of PPTalk. Try this: Add a new PPTalk object to your form and edit it to have this:

Code:
moveto(0,0)
Define(&num1,measure,0.0)
Define(&num2,measure,0.0)
Define(&total,measure,0.0)
set(&num1,strtofloat(strip(',',trimright(trimleft(@(1,510,523))))))
set(&num2,strtofloat(strip(',',trimright(trimleft(@(1,524,537))))))
set(&total,&num1 + &num2 )
show(floattostr(&total)
See if that works!

Neil.

Top
#20823 - 11/09/07 01:55 PM Re: Addition in a Local Variable
TanyaD Offline
OL User

Registered: 06/15/04
Posts: 55
Loc: Texas
I can't get all that to fit in the one line it allows me. I think I forgot to mention that I am using a local variable within a text box.
_________________________
Tanya D

Top
#20824 - 11/13/07 06:14 PM Re: Addition in a Local Variable
Anonymous
Unregistered


Hello,

Please remember that the box you are typing into is expecting a string as a result of what you do. The + sign when working with strings is concatination not addition. What you need to do is first convert both data selections to integers and add them up. Once that is done, you covert the sum back to a string.

Lets say your data file contained a number on line 1 and on line 2. This would work fine.

Code:
=inttostr(strtoint(@(1,1,3)) + strtoint(@(2,1,3)))
So you are taking the data on line 1 from columns 1 to 3 and converting it to a number. You then do the same thing with the data on line 2. They are then added together (since they are now numbers, the + means addition) and then, since we can only show strings and not numbers, we convert it back.

Top


Moderator:  cosimo, OL Newsgroup Support