Convert an equation within a list to be solved

Note- I am a relative noob to all of this, so apologies if errors are made…:smiley:
I am working on a script that will give me an accumulative word count by line in InDesign and place these values within a text box. I have been able to place a text box in the program and get a word count per line, but have as of yet figured out a way to make it cumulative. I have been able to get a list of numbers with addition signs within a list, which if I could then get the script to solve it, would be on my way to being able to finish the script. I basically would have the script return an equation such as “3+5+6+3+1+2+3+1+1+”, add a zero at the end and then get the sum of this equation. Is this possible?

A more direct route would be to ask for the count of the story’s words, but you can count the words of the lines and add them, if that’s really your goal. One way to do it is to assign the current number to a variable.

set theCount to 1
set theCount to theCount + ("This is five word's long."'s words count)

Marc has a good point but just in case you want to add numbers from a list…

set wordCountList to {1, 4, 6, 2, 8, 9}

set totalValue to ""
repeat with num in wordCountList
	set totalValue to totalValue + num
end repeat

totalValue -- result: 30

Thanks- I think that this is what I was looking for! I’m trying it out now and it looks promising! I’ll let you know.