I'm just trying to add up the numbers in line 18 of my text files titled "Clip Box.txt" which I have in each of my client files. For example, for one client, the value in line 18 might be $5,000 and in another it might be $3,000. So I want the script to total those numbers to give me the value of $8,000.
Here's my attempt (which isn't working):
Code: Select all
#SingleInstance Force
lst := ""
Total := "0"
var18 := "0"
Loop, files, C:\Clients\*, R
If (A_LoopFileName = "Clip Box.txt")
{
++count
FileReadLine, var18, % A_LoopFileFullPath, 18
Total+=var18 ; THIS IS THE PART WHICH ISN'T WORKING
lst .= var18 "|"
}
NumRows = %count%
sort, lst, D|
Gui, Font, s11
Gui, Add, ListBox, x11 w225 r%NumRows% vvar18, % lst ; THIS DISPLAYS ALL OF THE VALUES FOR VAR18 IN A LISTBOX, AND IT WORKS FINE
Gui, Add, Button, x11 w200, Done
Gui, Show
Return
ButtonDone:
Gui, Submit, Hide
MsgBox Total Retainer: $%Total% ; THIS GIVES ME AN INCORRECT VALUE (WAY LOWER THAN THE CORRECT SUM OF NUMBERS IN VAR18)
Return