kmeleon Posted May 11, 2011 Posted May 11, 2011 Hello I my script is problem with recursion in Date.au3 C:\Program Files (x86)\AutoIt3\Include\Date.au3 (1607) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.: If _DateIsLeapYear($iYear) Then $aiDays[2] = 29 ->13:01:28 AutoIT3.exe ended.rc:1 How fix this problem ? thx Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
guinness Posted May 11, 2011 Posted May 11, 2011 What does your Script look like because I have never had this happen before. I would also suggest having a looking at Recursion in the wiki by Melba23. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Tvern Posted May 11, 2011 Posted May 11, 2011 (edited) As far as I can see Date.au3 is not using any recursion that could cause problems, however if your script is reaching the maximum recursion level any function called at that point will exceed the maximum recursion level. As a test you could replace _DateIsLeapYear($iYear) in your script with something else. I suspect the error will occur regardless of what function is used. I cannot reproduce the error with the information you have given. _DateIsLeapYear() is not giving me any error for years 0000 to 9999, or even extrememly large, or negative values. If you could post your entire script, or a script that demonstrates the problem it'd be easier to help. Edit: This reproduces the error you describe, but the problem is not with Date.au3, but with the recursion in my (and I guess your) script. _DateIsLeapYear() is just one call too many, after my script already reached the maximum recursion level. #include <date.au3> _Recurse() Func _Recurse() _DaysInMonth(2011) _Recurse() EndFunc Edited May 11, 2011 by Tvern
kmeleon Posted May 11, 2011 Author Posted May 11, 2011 (edited) #include <date.au3> _Recurse() Func _Recurse() _DaysInMonth(2011) _Recurse() EndFunc Thanks for this code. I understand now this problem. I add sleep(1) in my code and is OK Thanks again Edited May 11, 2011 by kmeleon Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
Moderators Melba23 Posted May 11, 2011 Moderators Posted May 11, 2011 kmeleon,I understand now this problemNo you do not - because adding Sleep(1) to that code will not prevent the recursion. You cannot call a function from within itself unless you have an escape condition. You do not and so the function will continue to recurse until you hit the limit. Did you actually read the tutorial? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
guinness Posted May 11, 2011 Posted May 11, 2011 I too am confused to how you mis-read Tverns post?! Like Melba23 said Sleep() is just prolonging the inevitable UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
kmeleon Posted May 11, 2011 Author Posted May 11, 2011 (edited) OK. Knowing english by me is not very well. Sometime I not understand everything. But I have question? Why this code work ? #include <date.au3> _Recurse() Func _Recurse() _DaysInMonth(2011) sleep(1) _Recurse() EndFunc Edited May 11, 2011 by kmeleon Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
ProgAndy Posted May 11, 2011 Posted May 11, 2011 This code does not work. It just requires more time until the maximum level is reached ( + ~10ms per call of _recures) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Moderators Melba23 Posted May 11, 2011 Moderators Posted May 11, 2011 kmeleon, Why this code work ?It does not. - 1. Any Sleep value less that 10 is the same as Sleep(10) so you are pausing for 10ms each time. - 2. You are still calling the function from within the same function with no escape condition. AutoIt will continue to recurse until it reaches the limit. For me that takes 3898 calls and the script fails at 42 secs (approx 3900 * 10 = 39000ms = 39secs). Try running this to see what I mean - just let it run until it fails: #include <date.au3> $iCount = 0 _Recurse() Func _Recurse() $iCount += 1 ConsoleWrite($iCount & @CRLF) _DaysInMonth(2011) sleep(1) _Recurse() EndFunc Now do you understand? Please ask again if not M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kmeleon Posted May 11, 2011 Author Posted May 11, 2011 OK. I have bad code. I admite. You have right sleep(1) is wrong path.Thank you and sorry for the fact that I was stubborn Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
Moderators Melba23 Posted May 11, 2011 Moderators Posted May 11, 2011 kmeleon, No problem. Do you now understand why you had a recursion problem and how to solve it? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kmeleon Posted May 11, 2011 Author Posted May 11, 2011 I have some ideas why my script had a recursion. Tomorrow I will be search where is problem. If I fix my script I can say "I understand" now I can say I know more and I know what I must looking in my code. thanks a lot Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
Moderators Melba23 Posted May 11, 2011 Moderators Posted May 11, 2011 kmeleon,Tomorrow I will be search where is problem.You know where we are if you need any help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kmeleon Posted May 12, 2011 Author Posted May 12, 2011 I don't know how fix my problem with recursion. My code is it something like that >> local $i = 1 one() Func one() two() EndFunc Func two() three() EndFunc Func three() while 1 ;main loop ConsoleWrite("test" &$i &@CRLF) $i = $i + 1 four() WEnd EndFunc func four() five() EndFunc Func five() one() EndFunc Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
Tvern Posted May 12, 2011 Posted May 12, 2011 You need to allow functions to return (a function will return when it reaches EndFunc, or a line with Return) If function one calls function two, function one cannot return before function two does. If function two then calls function one (either directly, or through other functions) you create an stack of functions waiting to return. If the stack gets too big you get a the recursion error you posted. Instead you can call function one and then call function two once function one returns. place the functions in a loop if you want to repeat. Your example could be changed into something like this: local $i = 1 While 1 one() two() three() WEnd Func one() EndFunc Func two() EndFunc Func three() while 1 ;main loop ConsoleWrite("test" & $i & @CRLF) $i += 1 four() five() one() WEnd EndFunc func four() EndFunc Func five() EndFunc
kmeleon Posted May 12, 2011 Author Posted May 12, 2011 Thanks a lot It was so easy. Now is OK. Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
Moderators Melba23 Posted May 12, 2011 Moderators Posted May 12, 2011 kmeleon,Now is OK.Doskonałe. Tvern,Dankzij. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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