summing Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gregraphic

summing  Topic is solved

14 Jul 2018, 07:18

Noob here... :oops:
I have been at this off and on for days.
I have searched and read and experimented but now at a dead end.

I have a large file that I have stringsplit and appended to C:\TestIn\

C:\TestIn might now contain up to 500 files.
I want to sum the individual files. Each of which may contain eg:
0.60
1.20
.008
and append to C:\TestOut, but not sum the lot. So I end up with up to 500 files with the individual sums in each file eg:
1.88

I have this and tried many variations but it appends the sum to the next file

FileRead,T, C:\TestIn\%A_Index%.TXT

Loop, parse,T, `n `r

Sum+= A_LoopField

FileDelete,C:\TestOut\*.txt
FileAppend, %Sum%,C:\TestOut\%A_Index%.txt

Thanks for any help.
User avatar
SpeedMaster
Posts: 494
Joined: 12 Nov 2016, 16:09

Re: summing

15 Jul 2018, 05:48

gregraphic wrote:and append to C:\TestOut ... So I end up with up to 500 files
FileDelete,C:\TestOut\*.txt ----------> :problem: with this command, you will only end up with one file
gregraphic wrote:...but it appends the sum to the next file
Reset variable Sum to zero after each iteration of the loop Sum:=0

Code: Select all

loop, 500 {
FileRead,T, C:\TestIn\%A_Index%.TXT

Loop, parse,T, `n `r
Sum += A_LoopField

FileAppend, %Sum% , C:\TestOut\%A_Index%.txt

sum:=0
}
Cheers
astro8
Posts: 1
Joined: 14 Jul 2018, 06:01

Re: summing

15 Jul 2018, 06:04

Thanks very much. I appreciate your time.
I'll keep learning.....

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RussF and 372 guests