Sign in to follow this  
Followers 0
kmeleon

Recursion level in Date.au3 (1607)

17 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Tvern

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by kmeleon

Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

Share this post


Link to post
Share on other sites

kmeleon,

I understand now this problem

No 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? :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I too am confused to how you mis-read Tverns post?! Like Melba23 said Sleep() is just prolonging the inevitable :unsure:


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by kmeleon

Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

kmeleon,

No problem. :>

Do you now understand why you had a recursion problem and how to solve it? :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

kmeleon,

Tomorrow I will be search where is problem.

You know where we are if you need any help. :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thanks a lot :unsure:

It was so easy.

Now is OK.


Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

Share this post


Link to post
Share on other sites

kmeleon,

Now is OK.

Doskonałe. :unsure:

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0