Seems simple, but…

I am experienced in programming, but fairly new to Applescript. I have been playing with it, and I like what I see. However, I am stumped on something. It seems to me it should be simple, and perhaps it is, but damned if I can figure it out.

I need to add two long numbers together that come in as a string. For example:

set NumberOne to “20,000”
set NumberTwo to “50,000”
set NumberThree to “20,000.40”
set NumberFour to “50,000.70”

Now, all I need to do is end up with “NumberFive” as 70,000
Now, all I need to do is end up with “NumberSix” as 70,001.1

Anyone able to assist?

Hi,

coerce the first operand string to the appropriate number class


set NumberOne to "20000"
set NumberTwo to "50000"
set NumberThree to "20000.40"
set NumberFour to "50000.70"

set NumberFive to (NumberOne as integer) + NumberTwo
set NumberSix to (NumberThree as real) + NumberFour