rawkhopper 0 Posted June 3, 2019 (edited) Hello everybody, I have a script that I want to monitor some values over time. I thought this was a simple task, even for me, so I whipped out a script. The problem I have is that it seems to stop after a while. I use the script to write these values every 10 seconds to a text file so that I can later import the file into excel. The first time I got an error message but I didn't write it down (it was not one of my error messages I put in the script) I just assumed that someone messed with the computer it was running on and that caused an error. The second time I ran the file I did not see an error but I did see something peculiar. Both files had exactly 3794 lines. Am I doing something wrong or is this a limitation that I ran into? Or is this just a coincidence? Anyway if you see something wrong with my script please let me know. The script takes a long time to run and I do not always have access to the tool this runs on to test it out. So some expert eyes would be greatly appreciated! EDIT: I just tried to run the script with a dummy GUI to take info from and I got this error ("C:\Program Files (x86)\AutoIt3\Include\Date.au3" (1220) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:) I shortened the time so that I could get this error and it still ended up with 3794 lines looks like I must be doing something wrong with Date.au3? expandcollapse popup#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Date.au3> CreateFile() Func CreateFile() Global $FileName = @MyDocumentsDir & "\Current" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".txt" ; Create a file to write data to. If Not FileWrite($FileName, "Time" & "," & " " & "AccV" & "," & " " & "Emission" & "," & " " & "SIP-1" & "," & " " & "SIP-2" & "," & " " & "Spec" & "," & " " & "Probe Current" & @CRLF) Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the file.") Return False EndIf Global $hFileOpen = FileOpen($FileName, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") Return False EndIf Current() ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc Func Current() Local $Current = ControlGetText ( "Window", "", 1103 ) Local $AccV = ControlGetText ( "Window", "", 1001 ) Local $Emiss = ControlGetText ( "Window", "", 1912 ) Local $Sip1 = ControlGetText ( "Window", "", 1388 ) Local $Sip2 = ControlGetText ( "Window", "", 1390 ) Local $Spec = ControlGetText ( "Window", "", 1312 ) FileWrite( $hFileOpen, _NowTime() & "," & " " & $AccV & "," & " " & $Emiss & "," & " " & $Sip1 & "," & " " & $Sip2 & "," & " " & $Spec & "," & " " & $Current & @CRLF ) Sleep (10000) Current () EndFunc Edited June 3, 2019 by rawkhopper Share this post Link to post Share on other sites
KaFu 295 Posted June 3, 2019 Thats no limit of filewrite, but recursion: Global $Test_Recursion_Limit = 0 Test_Recursion_Limit() Func Test_Recursion_Limit() $Test_Recursion_Limit += 1 ConsoleWrite($Test_Recursion_Limit & @crlf) Test_Recursion_Limit() EndFunc OS: Win10-1909 - 64bit - German, AutoIt Version: 3.3.14.5, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2019-Dec-21) BIC - Batch-Image-Cropper (2019-Dec-11) COP - Color Picker (2009-May-21) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2019-Dec-07) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Share this post Link to post Share on other sites
rawkhopper 0 Posted June 3, 2019 What did I do wrong? Share this post Link to post Share on other sites
JLogan3o13 1,637 Posted June 3, 2019 Did you run the script provided? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Share this post Link to post Share on other sites
water 2,387 Posted June 3, 2019 You are calling function Current from within function Current. That's why you reach the recursion limit. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
rawkhopper 0 Posted June 3, 2019 Just now, water said: You are calling function Current from within function Current. That's why you reach the recursion limit. Hmm, how might I do this then? Should I call a different function that then calls current again? Share this post Link to post Share on other sites
rawkhopper 0 Posted June 3, 2019 Oh duh Sometimes I am an idiot... I just turned the stuff inside Current() to be a While loop and everything seems ok Thanks for pointing me in the right direction!!! Share this post Link to post Share on other sites
Exit 154 Posted June 3, 2019 Func Current() While True Local $Current = ControlGetText("Window", "", 1103) Local $AccV = ControlGetText("Window", "", 1001) Local $Emiss = ControlGetText("Window", "", 1912) Local $Sip1 = ControlGetText("Window", "", 1388) Local $Sip2 = ControlGetText("Window", "", 1390) Local $Spec = ControlGetText("Window", "", 1312) FileWrite($hFileOpen, _NowTime() & "," & " " & $AccV & "," & " " & $Emiss & "," & " " & $Sip1 & "," & " " & $Sip2 & "," & " " & $Spec & "," & " " & $Current & @CRLF) Sleep(10000) WEnd EndFunc ;==>Current App: Au3toCmd UDF: _SingleScript() Share this post Link to post Share on other sites
rawkhopper 0 Posted June 3, 2019 55 minutes ago, Exit said: Func Current() While True Local $Current = ControlGetText("Window", "", 1103) Local $AccV = ControlGetText("Window", "", 1001) Local $Emiss = ControlGetText("Window", "", 1912) Local $Sip1 = ControlGetText("Window", "", 1388) Local $Sip2 = ControlGetText("Window", "", 1390) Local $Spec = ControlGetText("Window", "", 1312) FileWrite($hFileOpen, _NowTime() & "," & " " & $AccV & "," & " " & $Emiss & "," & " " & $Sip1 & "," & " " & $Sip2 & "," & " " & $Spec & "," & " " & $Current & @CRLF) Sleep(10000) WEnd EndFunc ;==>Current Thanks, but I think I figured it out a few seconds before you posted!! Share this post Link to post Share on other sites