Jump to content

Sum return values of a function inside a loop


Recommended Posts

Hello AutoIT community, 
 

Without getting into too much details about the script. I have general question - what is the best way to sum return values of function inside a loop? I have limited programming skills and I don't seem to get it working.

An example of what the script should do: Script opens excel files from a selected folder and cleans the each file. CleanExcelFiles function returns integer $iCount which counts the amount of rows deleted in an excel file. 
 

Example()

Func Example()

Local $sFileSelectFolder = FileSelectFolder("", "")

$aFileList = _FileListToArray($sFileSelectFolder, "*.xls")

Local $iResult = 0
For $i = 1 To $aFileList[0]
    $sFile = $sFileSelectFolder & "\" & $aFileList[$i]
    
    OpenExcelFiles($sFile)

    $iResult = CleanExcelFiles()
    
Next

MsgBox("", "", "Total of "& $iResult& "actions were performed in all excels.")
EndFunc

Please advise a solution to sum all $iResults and return this total value after the script has finished cleaning all the excels.

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...