Odewallrus Posted September 24, 2010 Share Posted September 24, 2010 Ok… I apologize for the really basic newb question, but is someone could assist I would appreaciate it. I am using _LargeFileCopy and want to log errors to a gui log. The _LargeFileCopy returns 1 on success and 0 on failed and if failed sets @error. How can I log the actual error returned to my gui log. Here is what i have and is obviously not working out for me. ; Return values..: Success - 1 ; Failure - 0 and sets @error ; | 1 - Failed to open source file, or source was a directory ; | 2 - Destination file exists and overwrite flag not set ; | 3 - Failed to create destination file ; | 4 - Read error during copy ; | 5 - Write error during copy ; | 6 - Verify failed For $f = 1 to $FilesArray[0] $Answer = _LargeFileCopy($FilesArray[$f], '\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir, True, False, True, "1", Default, $CALG_MD5) if $Answer = 1 then GUICtrlSetData($GuiLog, 'Sucess: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f]) if $Answer = 0 then GUICtrlSetData($GuiLog, 'Failed: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f] & '' & @error) Next Link to comment Share on other sites More sharing options...
linus Posted September 24, 2010 Share Posted September 24, 2010 What exactly is not working? Link to comment Share on other sites More sharing options...
BrewManNH Posted September 24, 2010 Share Posted September 24, 2010 (edited) Try this: $hGuiLog = FileOpen($GuiLog, 1) ; Opens it for appending data to the file For $f = 1 to $FilesArray[0] $Answer = _LargeFileCopy($FilesArray[$f], '\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir, True, False, True, "1", Default, $CALG_MD5) if $Answer = 1 then FileWriteLine($hGuiLog, 'Success: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f]) if $Answer = 0 then FileWriteLine($hGuiLog, 'Failed: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f] & '' & @error) Next FileClose($hGuiLog) Edited September 24, 2010 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Odewallrus Posted September 24, 2010 Author Share Posted September 24, 2010 Try this: $hGuiLog = FileOpen($GuiLog, 1) ; Opens it for appending data to the file For $f = 1 to $FilesArray[0] $Answer = _LargeFileCopy($FilesArray[$f], '\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir, True, False, True, "1", Default, $CALG_MD5) if $Answer = 1 then FileWriteLine($hGuiLog, 'Success: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f]) if $Answer = 0 then FileWriteLine($hGuiLog, 'Failed: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f] & '' & @error) Next FileClose($hGuiLog) I am getting the log written with everything except the @error value at the end when a failure occurs. Currently the GUI log is a GUICtrlCreateList on the GUI itself. Link to comment Share on other sites More sharing options...
linus Posted September 24, 2010 Share Posted September 24, 2010 (edited) then try this: $Answer = _LargeFileCopy($FilesArray[$f], '\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir, True, False, True, "1", Default, $CALG_MD5) $myError = @error if $Answer = 1 then GUICtrlSetData($GuiLog, 'Sucess: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f]) if $Answer = 0 then GUICtrlSetData($GuiLog, 'Failed: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f] & '' & $myError) or this should also work: _LargeFileCopy($FilesArray[$f], '\\' & $aHosts[$n][1] & '\' & $aHosts[$n][3] & '\' & $DestDir, True, False, True, "1", Default, $CALG_MD5) if @error then GUICtrlSetData($GuiLog, 'Failed: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f] & '' & @error) else GUICtrlSetData($GuiLog, 'Sucess: ' & $aHosts[$n][1] & ' ' & $FilesArray[$f]) endif @error is reset after every function call, in this case after FileWriteLine's. Edited September 24, 2010 by linus Link to comment Share on other sites More sharing options...
BrewManNH Posted September 24, 2010 Share Posted September 24, 2010 Try setting a variable to the @error value and use that variable instead of the actual @error macro. It's possible it's grabbing the @error for some other command you're using such as the GUICtrlSetData function. I haven't tested it that way, but it's possible. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Odewallrus Posted September 28, 2010 Author Share Posted September 28, 2010 Try setting a variable to the @error value and use that variable instead of the actual @error macro. It's possible it's grabbing the @error for some other command you're using such as the GUICtrlSetData function. I haven't tested it that way, but it's possible.That worked for me.Does someone have a code example of how to use the $sFunction parameter in _LargeFileCopy. I am trying to learn how to incorporate a (multiple… current file and total files) progress bars into my app. 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