alexrotaru Posted May 10, 2006 Posted May 10, 2006 hy, i have a problem with one of my scripts: sometimes (usually the first time i run the script) i find in my log the script code. sometimes the code is not only once written, but for 3 or 4 times. i don't know why this is happening. it always happens in the same place. to write in the log file I have created my own function (not using the one that comes with autoit): ;=====================================================================; ; Description: writes in the log file ; Syntax: writeInLog ($_LogFileDesc, $_LogText, $_Flag) ; Parameter(s): $_LogFileDesc - the file descriptor of the log file ; $_LogText - the text that will be written in the log file ; $_Flag - the flag that specifies if this is a regular message or the beginning/end of the log ; (0 = beginning/end of log; 1 = regular message) ; Requirement(s): None ; Return Value(s): On Success - Nothing ; On Failure - a message box appears informing that it was not possible to write in the log, and then the script exits ; Author(s): Alexandru ; Note(s): ; ;===================================================================== Func writeInLog ($_LogFileDesc, $_LogText, $_Flag) Dim $_WriteFile ; if $_Flag is zero, then this is the first/last time we are writing in the log file If $_Flag == 0 Then $_WriteFile = FileWrite ($_LogFileDesc,"-----------------" & @CRLF & _ @MON & "/" & @MDAY & "/" & @YEAR & " " & _ @HOUR & ":" & @MIN & ":" & @SEC & " " & _ $_LogText & @CRLF & _ "-----------------" & @CRLF _ ) ; if $_Flag is not zero, then this is not the first time we are writing in the log file Else $_WriteFile = FileWrite ($_LogFileDesc, @MON & "/" & @MDAY & "/" & @YEAR & " " & _ @HOUR & ":" & @MIN & ":" & @SEC & " " & $_LogText & @CRLF _ ) EndIf ; checking to see if it was possible to write in the log file If $_WriteFile == 0 Then MsgBox (0, "script error message", "unable to write to the log file") Exit EndIf EndFunc ; ==> writeInLog i was wandering if anyone else has encountered the same problem. i have attached two log files: - log.txt is a "good" log, this means that the code is not present in the log - log_old2.txt is a "bad" log, this means that the code is present in the log if you need any more info, please tell me and I will provide it as soon as possible. thankslog.txtlog_old2.txt
Gyzmok Posted May 10, 2006 Posted May 10, 2006 This is an extract of your code just before and when it starts writing code in your log : expandcollapse popup... If FileClose ($_TempLogDesc) == 0 Then MsgBox (0, "script error message", "the temporary file handle is invalid. the file could not be closed") Exit EndIf ; copy the content of the temporary log file to the log file from the configuration file If fileToFile (@WorkingDir & "/templog.txt", $_LogFile.text) == 0 Then MsgBox (0, "script error message", "the temporary log could not be moved to the log file") Exit EndIf ; opening the log file $_LogFileDesc = FileOpen ($_LogFile.text, 9) ; if the log file cannot be opened/created, then the script will exit If $_LogFileDesc == -1 Then MsgBox (0, "script error message", "the log file could not be opened") Exit EndIf writeInLog ($_LogFileDesc, "setting the mouse position", 1) ; puts the mouse to a position where nothing happens :) MouseMove (0, 600) ; executing the test steps execTestSteps ($_XmlDomDocSteps, $_LogFileDesc) Sleep (3000) ; closing the Internet Explorer window ;Send ("!{F4}") writeInLog ($_TempLogDesc, "ending the log ", 0) ; closing the log file FileClose ($_LogFileDesc) ... I could be wrong, but : FileClose ($_TempLogDesc) will close the $_TempLogDesc log file. and at the end of the code there is this line : writeInLog ($_TempLogDesc, "ending the log ", 0) It seems to me that log file $_TempLogDesc is not open at that moment ... Maybe it should be : writeInLog ($_LogFileDesc, "ending the log ", 0) ?? D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
alexrotaru Posted May 10, 2006 Author Posted May 10, 2006 thanks for your observation. i forgot to change the descriptor :-). although this has not solved my problem. strange that autoit did not say anything about using a file descriptor that did not exist. i forgot to say that I am using Scite editor, and I start the script from the editor using the F5 key. I think that it might have to do with it (it shows the file opened by the editor).
Gyzmok Posted May 10, 2006 Posted May 10, 2006 Does it also happen when using F7(build) and execute the compiled version of your script ? I also use Scite and never had any problem like this. Could it be in "execTestSteps ($_XmlDomDocSteps, $_LogFileDesc)" or in #include <alexFunctions.au3> ?? D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
alexrotaru Posted May 10, 2006 Author Posted May 10, 2006 you were right, the problem was not in scite. i run the .exe file and this time it showed me information about total commnander . one of my functions does something nasty, but i don't know exactly where this happens. i will try to look again. what i find strange is that this does not happen every time.... thanks a lot for your help. if you have any other ideeas about why this is happenning....
alexrotaru Posted May 10, 2006 Author Posted May 10, 2006 now I feel realy stupid :-(. I found the problem. it was nothing wrong...i was printing page info for debug pupose, and because the new application needed some time to load, autoit was retreiving information of the current active window (scite, or totoal commander). :-( thanks a lot for you time.
Gyzmok Posted May 10, 2006 Posted May 10, 2006 (edited) No problem Glad you found it. Edited May 10, 2006 by Gyzmok D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
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