rawkhopper Posted June 3, 2019 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
KaFu Posted June 3, 2019 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-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Moderators JLogan3o13 Posted June 3, 2019 Moderators 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!
water Posted June 3, 2019 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
rawkhopper Posted June 3, 2019 Author 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?
rawkhopper Posted June 3, 2019 Author 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!!!
Exit Posted June 3, 2019 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()
rawkhopper Posted June 3, 2019 Author 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!!
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