AIisKing Posted January 16, 2021 Posted January 16, 2021 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.
Nine Posted January 16, 2021 Posted January 16, 2021 $iResult += CleanExcelFiles() That will sum up all results “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
AIisKing Posted January 16, 2021 Author Posted January 16, 2021 (edited) @Nine I was thinking about +=, but for some reason I was getting syntax error. What can be the case that I get syntax error? The CleanExcelFiles return integer $iCount. Edited January 17, 2021 by AIisKing
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now