DrOtosclerosi Posted August 14, 2020 Share Posted August 14, 2020 Hi everyone, I hope I will be clear enough, this topic is quite difficult to explain. So, I wrote a management software for my company, were we all insert our works and each work is stored in a xml file containing all the infos of that specific work (date, time, customer, activity, products...). Everything is working really well and we are using it without problems, except this one. In the program there's a search function, which performs some checks and then copy the xml file in a folder that will be used by the search navigation function. Long story short, the part of the code is this: $Generic_Array = _FileListToArray(@ScriptDir & '\Data\XML') For $c = 1 To $Generic_Array[0] ;MANY CONDITIONALS TO CHECK THE CONDITIONS ;If all conditions are satisfied, then $CopyCode = FileCopy(@ScriptDir & "\Data\XML\" & $Rapportini_Array_Generico[$c], @ScriptDir & "\Data\Temp\Search\") if Not($CopyCode = 1) Then While Not($CopyCode = 1) $CopyCode = FileCopy(@ScriptDir & "\Data\XML\" & $Rapportini_Array_Generico[$c], @ScriptDir & "\Data\Temp\Search\") WEnd EndIf Next This is working good, filters are applied and the right xmls are copied. Then the software reads the search folder with this: ControlClick($rapportini, "", $BrowseNext) Where the GUI button $BrowseNext starts a function that loads the next xml in the folder on the GUI (so the first one is loaded automatically and then the user can browse next or previous xml). Again, this is working good on my machine, which is an high performance machine. On the PC that another user uses, this is not working good. The filters are applied, the xml are copied but there are always some xml missing. For example, one of the fields in the xml is "Completed" and can be True or False: if the "Completed" filter is set to False on my PC, all the xml that are not completed are copied and loaded. On his PC only, let's say, 3/4 of them are copied and loaded. Then if he do another search with the same parameter, other not completed xml shows up. So he has to do let's say 2-3 searches to be sure that he have all the not completed xmls. I think the problem is related to FileCopy performances or to the fact that while searching the software loops into a list of thousand files. But I can't understand what could be the problem: after all, the FileCopy function should wait until the file is effectively copied, right? So low performances could impact on the search being slow, but not being incomplete. Right? I really can't get it. I'm sure is something performance related 'cause on high end machines it always works good, and on that low end machine it always gives this problem, especially when the machine is burdened with other processes. Otherwise, the code works flawlessy. If there's a workaround (for example to be sure that explorer really copied the xml or an alternative to FileCopy), I'd be happy anyway. Link to comment Share on other sites More sharing options...
Zedna Posted August 14, 2020 Share Posted August 14, 2020 General advice: add logging functionality, ie. create LOG file with all information including return values of your commands and possibly also @error states. Then compare these LOG files from high end PCs and low end PCs ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
rudi Posted September 7, 2020 Share Posted September 7, 2020 Adjust this to your needs and check the output: $Generic_Array = _FileListToArray(@ScriptDir & '\Data\XML') For $c = 1 To $Generic_Array[0] ;MANY CONDITIONALS TO CHECK THE CONDITIONS ;If all conditions are satisfied, then $Src = @ScriptDir & "\Data\XML\" & $Rapportini_Array_Generico[$c] ConsoleWrite("Next $Src = " & $Src & @CRLF) $Dst = @ScriptDir & "\Data\Temp\Search\" & $Rapportini_Array_Generico[$c] If FileExists($Dst) Then ConsoleWrite("$Dst *ALREADY* exists: " & $Dst & @CRLF) ; filecopy() should either always succeed, or always fail. Anyway, give it a max of 10 tries... For $try = 1 To 10 $Result = FileCopy($Src, $Dst, 1 + 8) ; overwrite, create path $err = @error If $Result Then ConsoleWrite(@TAB & "Try #" & $try & ": Copy done" & @CRLF) ExitLoop Else ConsoleWrite("ERROR copy try #" & $try & @CRLF) EndIf Next Next Rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
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