# Recursion level limit

## Recommended Posts

Aha. Roger.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...

##### Share on other sites

I updated the code from post#1. Now you can see how it works.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

I modified the code from post#1 slightly.

Can somebody explain me why the recursion stack limit is reached when starting at coordinate 0,0 at \$iRec = 13269 but when starting it with coordinate 82, 24 it will not break and \$iRec is 28989.

This is the result on my machine and may differ on yours.

Thanks,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

The reason is that the recursion count with 0,0 hits 3900, which is the limit for x64 systems:

Changed your debug a little to demonstrate it:

#include <GDIPlus.au3>
Global \$recur = 1

\$sRegPath = "HKLM\SOFTWARE\AutoIt v3\AutoIt"
If StringInStr("X64IA64", @OSArch) Then \$sRegPath = StringReplace(\$sRegPath, "SOFTWARE", "SOFTWARE\Wow6432Node")

_GDIPlus_Startup()
\$iW = _GDIPlus_ImageGetWidth(\$hImage)
\$iH = _GDIPlus_ImageGetHeight(\$hImage)
\$hGUI = GUICreate("Test", \$iW, \$iH)
GUISetState()
\$hGfx = _GDIPlus_GraphicsCreateFromHWND(\$hGUI)

\$iColor2Fill = 0xFFFFFFFF
_GDIPlus_FloodFill(\$hImage, 0, 0, 0xFF000080, 0xFFFFFF00)
;~ _GDIPlus_FloodFill(\$hImage, 82, 24, 0xFF000080, 0xFFFFFF00)
_GDIPlus_ImageSaveToFile(\$hImage, @ScriptDir & "\Filled.png")
;~ ShellExecute(@ScriptDir & "\Filled.png")
ConsoleWrite("Done" & @LF)
Do
Until GUIGetMsg() = -3

_GDIPlus_ImageDispose(\$hImage)
_GDIPlus_GraphicsDispose(\$hGfx)
_GDIPlus_Shutdown()
Exit

Func _GDIPlus_FloodFill(ByRef \$hBitmap, \$iX, \$iY, \$iColorOld, \$iColorNew) ;coded by UEZ 2013-01-11
Local Static \$iRec = 1
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : \$recur = ' & \$recur & ' \$iRec = ' & \$iRec & ' >Error code: ' & @error & @CRLF) ;### Debug Console
;~   If \$iRec > 13268 Then Return -1 ;max recursion stack reached
Local \$aResult = DllCall(\$ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", \$hBitmap, "int", \$iX, "int", \$iY, "uint*", 0)
If \$aResult[4] = "0x" & Hex(\$iColorOld, 8) Then
DllCall(\$ghGDIPDll, "uint", "GdipBitmapSetPixel", "handle", \$hBitmap, "int", \$iX, "int", \$iY, "uint", \$iColorNew)
;~       Sleep(10)
Else
Return 0
EndIf
\$iRec += 1
\$aResult = DllCall(\$ghGDIPDll, "uint", "GdipGetImageDimension", "handle", \$hBitmap, "float*", 0, "float*", 0)
If (\$iX + 1) < \$aResult[2] + 1 Then
\$iRec += 1
\$recur += 1
_GDIPlus_FloodFill(\$hBitmap, \$iX + 1, \$iY, \$iColorOld, \$iColorNew) ;go east
\$recur -= 1
EndIf
If (\$iY + 1) < \$aResult[3] + 1 Then
\$iRec += 1
\$recur += 1
_GDIPlus_FloodFill(\$hBitmap, \$iX, \$iY + 1, \$iColorOld, \$iColorNew) ;go south
\$recur -= 1
EndIf
If (\$iX - 1) > -1 Then
\$iRec += 1
\$recur += 1
_GDIPlus_FloodFill(\$hBitmap, \$iX - 1, \$iY, \$iColorOld, \$iColorNew) ;go west
\$recur -= 1
EndIf
If (\$iY - 1) > -1 Then
\$iRec += 1
\$recur += 1
_GDIPlus_FloodFill(\$hBitmap, \$iX, \$iY - 1, \$iColorOld, \$iColorNew) ;go north
\$recur -= 1
EndIf
Return 1
EndFunc ;==>_GDIPlus_FloodFill

Func UpdateView()
_GDIPlus_GraphicsDrawImage(\$hGfx, \$hImage, 0, 0)
EndFunc ;==>UpdateView

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Thanks for the clarification Jos.

That means the stack will be decreased when returning from the function. That was a misunderstanding from me.

\$iRec is the sum of recursion calls not the recursion level.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

Maybe trancexx or Jon can comment here, but looking at the source it seems we have a 3900 limit for x64 and a 1900 limit for x86 for both Call and Execute while the helpfile states 5100.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Stack-based recursion is awesome. I had to do something similar in node.js a few months ago, like monoceres pointed out, visualizing the output from it is cool

##### Share on other sites

Here the iterative version which is much slower because I used an array for the stack simulation:

#include <Array.au3>
#include <GDIPlus.au3>;~~~

\$sRegPath = "HKLM\SOFTWARE\AutoIt v3\AutoIt"
If StringInStr("X64IA64", @OSArch) Then \$sRegPath = StringReplace(\$sRegPath, "SOFTWARE", "SOFTWARE\Wow6432Node")

_GDIPlus_Startup()
\$iW = _GDIPlus_ImageGetWidth(\$hImage)
\$iH = _GDIPlus_ImageGetHeight(\$hImage)
\$hGUI = GUICreate("Test", \$iW, \$iH)
GUISetState()
\$hGfx = _GDIPlus_GraphicsCreateFromHWND(\$hGUI)

\$iColor2Fill = 0xFFFFFFFF
;~ _GDIPlus_FloodFillRecRec(\$hImage, 0, 0, 0xFF000080, 0xFFFFFF00)
_GDIPlus_FloodFillRecIter(\$hImage, 0, 0, 0xFF000080, 0xFFFFFF00)
_GDIPlus_ImageSaveToFile(\$hImage, @ScriptDir & "\Filled.gif")
;~ ShellExecute(@ScriptDir & "\Filled.png")
ConsoleWrite("Done" & @LF)
Do
Until GUIGetMsg() = -3

_GDIPlus_ImageDispose(\$hImage)
_GDIPlus_GraphicsDispose(\$hGfx)
_GDIPlus_Shutdown()
Exit

Func _GDIPlus_FloodFillRecIter(ByRef \$hBitmap, \$iX, \$iY, \$iColorOld, \$iColorNew) ;coded by UEZ 2013-01-12
Local \$aResult = DllCall(\$ghGDIPDll, "uint", "GdipGetImageDimension", "handle", \$hBitmap, "float*", 0, "float*", 0)
Local \$iW = \$aResult[2], \$iH = \$aResult[3]
If BitOR(\$iX < 0, \$iY < 0, \$iX > \$iW - 1, \$iY > \$iH - 1) Then
Return 0
EndIf
Local \$x, \$y
Local \$aStack[1] ;stack ->x,y coordinate
_ArrayAdd(\$aStack, \$iX & ";" & \$iY)
While UBound(\$aStack)  > 1
\$sPoint = \$aStack[UBound(\$aStack) - 1]
_ArrayDelete(\$aStack, UBound(\$aStack) - 1) ;pop
\$x = Int(StringRegExpReplace(\$sPoint, "(\d+);\d+", "\$1"))
\$y = Int(StringRegExpReplace(\$sPoint, "\d+;(\d+)", "\$1"))
If BitOR(\$x< 0, \$y < 0, \$x > \$iW - 1, \$y > \$iH - 1) Then ContinueLoop
\$aResult = DllCall(\$ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", \$hBitmap, "int", \$x, "int", \$y, "uint*", 0)
If \$aResult[4] = "0x" & Hex(\$iColorOld, 8) Then
DllCall(\$ghGDIPDll, "uint", "GdipBitmapSetPixel", "handle", \$hBitmap, "int", \$x, "int", \$y, "uint", \$iColorNew)
_ArrayAdd(\$aStack, \$x + 1 & ";" & \$y) ;push
_ArrayAdd(\$aStack, \$x & ";" & \$y + 1) ;push
_ArrayAdd(\$aStack, \$x - 1 & ";" & \$y) ;push
_ArrayAdd(\$aStack, \$x & ";" & \$y - 1) ;push
EndIf
WEnd
EndFunc

Func _GDIPlus_FloodFillRec(ByRef \$hBitmap, \$iX, \$iY, \$iColorOld, \$iColorNew) ;coded by UEZ 2013-01-12
Local Static \$iRec = 1
If \$iRec = 3898 Then
ConsoleWrite("max recursion level has been reached" & @LF)
Return -1 ;max recursion level has been reached
EndIf
Local \$aResult = DllCall(\$ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", \$hBitmap, "int", \$iX, "int", \$iY, "uint*", 0)
If \$aResult[4] = "0x" & Hex(\$iColorOld, 8) Then
DllCall(\$ghGDIPDll, "uint", "GdipBitmapSetPixel", "handle", \$hBitmap, "int", \$iX, "int", \$iY, "uint", \$iColorNew)
Else
Return 0
EndIf
\$aResult = DllCall(\$ghGDIPDll, "uint", "GdipGetImageDimension", "handle", \$hBitmap, "float*", 0, "float*", 0)
If (\$iX + 1) < \$aResult[2] + 1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX + 1, \$iY, \$iColorOld, \$iColorNew) ;go east
\$iRec -= 1
EndIf
If (\$iY + 1) < \$aResult[3] + 1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX, \$iY + 1, \$iColorOld, \$iColorNew) ;go south
\$iRec -= 1
EndIf
If (\$iX - 1) > -1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX - 1, \$iY, \$iColorOld, \$iColorNew) ;go west
\$iRec -= 1
EndIf
If (\$iY - 1) > -1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX, \$iY - 1, \$iColorOld, \$iColorNew) ;go north
\$iRec -= 1
EndIf
Return 1
EndFunc

Func UpdateView()
_GDIPlus_GraphicsDrawImage(\$hGfx, \$hImage, 0, 0)
EndFunc

Searching for a much faster stack simulation code!

Btw, how can I use AutoIt objects to do some p.x or p.y to read/write it?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

Use a dictionary object, much faster than an array.

Alternatively do not use the Array UDF functions, as they redim the array on each call. Redim the array only every 500 or 1000 elements and perform the additions and deletions manually with an own counter... but I still would first try the dictionary object ...

Edit: Wasn't there something with vtables in the last beta? Wouldn't this be a good application for those?

Edited by KaFu

OS: Win10-1803 - 64bit - German, AutoIt Version: 3.3.14.5, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ...

##### Share on other sites

Try this one... its a little faster

#include <Array.au3>
#include <GDIPlus.au3>;~~~

\$sRegPath = "HKLM\SOFTWARE\AutoIt v3\AutoIt"
If StringInStr("X64IA64", @OSArch) Then \$sRegPath = StringReplace(\$sRegPath, "SOFTWARE", "SOFTWARE\Wow6432Node")

_GDIPlus_Startup()
\$iW = _GDIPlus_ImageGetWidth(\$hImage)
\$iH = _GDIPlus_ImageGetHeight(\$hImage)
\$hGUI = GUICreate("Test", \$iW, \$iH)
GUISetState()
\$hGfx = _GDIPlus_GraphicsCreateFromHWND(\$hGUI)

\$iColor2Fill = 0xFFFFFFFF
;~ _GDIPlus_FloodFillRecRec(\$hImage, 0, 0, 0xFF000080, 0xFFFFFF00)
_GDIPlus_FloodFillRecIter(\$hImage, 0, 0, 0xFF000080, 0xFFFFFF00)
_GDIPlus_ImageSaveToFile(\$hImage, @ScriptDir & "\Filled.gif")
;~ ShellExecute(@ScriptDir & "\Filled.png")
ConsoleWrite("Done" & @LF)
Do
Until GUIGetMsg() = -3

_GDIPlus_ImageDispose(\$hImage)
_GDIPlus_GraphicsDispose(\$hGfx)
_GDIPlus_Shutdown()
Exit

Func _GDIPlus_FloodFillRecIter(ByRef \$hBitmap, \$iX, \$iY, \$iColorOld, \$iColorNew) ;coded by UEZ 2013-01-12
Local \$aResult = DllCall(\$ghGDIPDll, "uint", "GdipGetImageDimension", "handle", \$hBitmap, "float*", 0, "float*", 0)
Local \$iW = \$aResult[2], \$iH = \$aResult[3]
If BitOR(\$iX < 0, \$iY < 0, \$iX > \$iW - 1, \$iY > \$iH - 1) Then
Return 0
EndIf
Local \$x, \$y
Local \$aStack[5000] ;stack ->x,y coordinate
Local \$iStack = 1
StackAdd(\$aStack, \$iX & ";" & \$iY, \$iStack)
While \$iStack > 0
\$sPoint = \$aStack[\$iStack - 1]
StackDelete(\$aStack, \$iStack) ;pop
\$x = Int(StringRegExpReplace(\$sPoint, "(\d+);\d+", "\$1"))
\$y = Int(StringRegExpReplace(\$sPoint, "\d+;(\d+)", "\$1"))
If BitOR(\$x< 0, \$y < 0, \$x > \$iW - 1, \$y > \$iH - 1) Then ContinueLoop
\$aResult = DllCall(\$ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", \$hBitmap, "int", \$x, "int", \$y, "uint*", 0)
If \$aResult[4] = "0x" & Hex(\$iColorOld, 8) Then
DllCall(\$ghGDIPDll, "uint", "GdipBitmapSetPixel", "handle", \$hBitmap, "int", \$x, "int", \$y, "uint", \$iColorNew)
StackAdd(\$aStack, \$x + 1 & ";" & \$y,  \$iStack) ;push
StackAdd(\$aStack, \$x & ";" & \$y + 1,  \$iStack) ;push
StackAdd(\$aStack, \$x - 1 & ";" & \$y,  \$iStack) ;push
StackAdd(\$aStack, \$x & ";" & \$y - 1,  \$iStack) ;push
EndIf
WEnd
EndFunc

Func _GDIPlus_FloodFillRec(ByRef \$hBitmap, \$iX, \$iY, \$iColorOld, \$iColorNew) ;coded by UEZ 2013-01-12
Local Static \$iRec = 1
If \$iRec = 3898 Then
ConsoleWrite("max recursion level has been reached" & @LF)
Return -1 ;max recursion level has been reached
EndIf
Local \$aResult = DllCall(\$ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", \$hBitmap, "int", \$iX, "int", \$iY, "uint*", 0)
If \$aResult[4] = "0x" & Hex(\$iColorOld, 8) Then
DllCall(\$ghGDIPDll, "uint", "GdipBitmapSetPixel", "handle", \$hBitmap, "int", \$iX, "int", \$iY, "uint", \$iColorNew)
Else
Return 0
EndIf
\$aResult = DllCall(\$ghGDIPDll, "uint", "GdipGetImageDimension", "handle", \$hBitmap, "float*", 0, "float*", 0)
If (\$iX + 1) < \$aResult[2] + 1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX + 1, \$iY, \$iColorOld, \$iColorNew) ;go east
\$iRec -= 1
EndIf
If (\$iY + 1) < \$aResult[3] + 1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX, \$iY + 1, \$iColorOld, \$iColorNew) ;go south
\$iRec -= 1
EndIf
If (\$iX - 1) > -1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX - 1, \$iY, \$iColorOld, \$iColorNew) ;go west
\$iRec -= 1
EndIf
If (\$iY - 1) > -1 Then
\$iRec += 1
_GDIPlus_FloodFillRec(\$hBitmap, \$iX, \$iY - 1, \$iColorOld, \$iColorNew) ;go north
\$iRec -= 1
EndIf
Return 1
EndFunc

Func UpdateView()
_GDIPlus_GraphicsDrawImage(\$hGfx, \$hImage, 0, 0)
EndFunc
;
Func StackAdd(Byref \$aStack, \$SVal,ByRef \$iStack)
If \$iStack+2 > UBound(\$aStack) then ReDim \$aStack[\$iStack+500]
\$aStack[\$iStack] = \$SVal
\$iStack += 1
EndFunc
;
Func StackDelete(ByRef \$aStack,Byref \$iStack)
\$iStack -= 1
EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Thanks guys!

Currently I was doing also some tuning for the stack implementation but the array was implemented just to test whether it will work or not.

One of my ideas was also to use dictionary object as suggested by KaFu.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

Here the Scripting Dictionary iterative version

#include <GDIPlus.au3>

\$sRegPath = "HKLM\SOFTWARE\AutoIt v3\AutoIt"
If StringInStr("X64IA64", @OSArch) Then \$sRegPath = StringReplace(\$sRegPath, "SOFTWARE", "SOFTWARE\Wow6432Node")

_GDIPlus_Startup()
\$iW = _GDIPlus_ImageGetWidth(\$hImage)
\$iH = _GDIPlus_ImageGetHeight(\$hImage)
\$hGUI = GUICreate("Test", \$iW, \$iH)
GUISetState()
\$hGfx = _GDIPlus_GraphicsCreateFromHWND(\$hGUI)

\$iColor2Fill = 0xFFFFFFFF
_GDIPlus_FloodFillIter2(\$hImage, 0, 0, 0xFF000080, 0xFFFFFF00)
_GDIPlus_ImageSaveToFile(\$hImage, @ScriptDir & "\Filled.png")
;~ ShellExecute(@ScriptDir & "\Filled.png")
ConsoleWrite("Done" & @LF)
Do
Until GUIGetMsg() = -3

_GDIPlus_ImageDispose(\$hImage)
_GDIPlus_GraphicsDispose(\$hGfx)
_GDIPlus_Shutdown()
Exit

Func _GDIPlus_FloodFillIter2(ByRef \$hBitmap, \$iX, \$iY, \$iColorOld, \$iColorNew) ;coded by UEZ 2013-01-13
Local \$aResult = DllCall(\$ghGDIPDll, "uint", "GdipGetImageDimension", "handle", \$hBitmap, "float*", 0, "float*", 0)
Local \$iW = \$aResult[2], \$iH = \$aResult[3]
If BitOR(\$iX < 0, \$iY < 0, \$iX > \$iW - 1, \$iY > \$iH - 1) Then Return SetError(1, 0, 0)
Local \$x, \$y, \$i = 1
Local \$oD = ObjCreate('Scripting.Dictionary')
\$oD.Add(\$i, \$iX & ";" & \$iY) ;push
\$i += 1
While \$oD.Count > 0
\$sPoint = \$oD.Item(\$i - 1)
\$oD.Remove(\$i - 1) ;pop
\$i -= 1
\$x = Int(StringRegExpReplace(\$sPoint, "(\d+);\d+", "\$1"))
\$y = Int(StringRegExpReplace(\$sPoint, "\d+;(\d+)", "\$1"))
If BitOR(\$x < 0, \$y < 0, \$x > \$iW - 1, \$y > \$iH - 1) Then ContinueLoop
\$aResult = DllCall(\$ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", \$hBitmap, "int", \$x, "int", \$y, "uint*", 0)
If \$aResult[4] = "0x" & Hex(\$iColorOld, 8) Then
DllCall(\$ghGDIPDll, "uint", "GdipBitmapSetPixel", "handle", \$hBitmap, "int", \$x, "int", \$y, "uint", \$iColorNew)
\$oD.Add(\$i, \$x + 1 & ";" & \$y) ;push
\$i += 1
\$oD.Add(\$i, \$x & ";" & \$y + 1) ;push
\$i += 1
\$oD.Add(\$i, \$x - 1 & ";" & \$y) ;push
\$i += 1
\$oD.Add(\$i, \$x & ";" & \$y - 1) ;push
\$i += 1
EndIf
WEnd
\$oD = 0
Return 1
EndFunc   ;==>_GDIPlus_FloodFillIter2

Func UpdateView()
_GDIPlus_GraphicsDrawImage(\$hGfx, \$hImage, 0, 0)
EndFunc

@Jos: While \$iStack > 0 must be While \$iStack > 1, otherwise flooding will continue at 0, 0.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

Now, well done, seems fast enough for me .

OS: Win10-1803 - 64bit - German, AutoIt Version: 3.3.14.5, AutoIt Editor: SciTE, Website: http://www.funk.eu, My unsolved Questions: Get default Window Size and Position, Rotate display by 270 degrees, Get Systray Icons, ...

##### Share on other sites

Maybe trancexx or Jon can comment here, but looking at the source it seems we have a 3900 limit for x64 and a 1900 limit for x86 for both Call and Execute while the helpfile states 5100.

Jos

It changes each version. I didn't even know it was in the helpfile. It should probably be removed.

##### Share on other sites

Do I remove it?

Might be worth keeping a note that there is a recursion limit. It's one of those gotchas for people who haven't programmed before that still comes up as a question from time to time.

##### Share on other sites

But how to word it so it doesn't raise questions of: What is the limit?

When you call a function, an entry ("frame") is added to the call stack. Further nested function calls add to this stack and returning from a function removes its entry. The call stack has a fixed size, which depends on the version of AutoIt being run, but is made large enough that it should only be overflowed by very deep or infinite recursion. If a function is likely to call itself more than 1000 times then you should switch to an iterative method (one involving loops).

That's a very rough attempt. Does have to give some sort of reference to the stack size being in the order of a thousand.

##### Share on other sites

I can't say. If the call stack is direct and fixed size, the limit should strongly depend on the number, type and size of parameters pushed at each round. If the stack is indirect, then merely depends on 32- vs 64-bit and release (but in this case it's questionable that a recursion limit even exists, beside process memory exhausted). Only devs can say for sure.

In the later case, maybe a simple runable script made available online would avoid too many "how much" questions, so that users can actually determine themselves which is the limit for the installation they use. If the former style is in fact in use, then users would have to try by themselves with the exact function prototype they use in their real-world application. All of this provided that OnAutoItExitRegister can actually run a function which prints a variable, which is far from obvious in case of stack overflow. But using ConsoleWrite can overcome the issue, as we're not talking about billion recursions/lines. Can't test that from where I am currently.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

Can't test that from where I am currently.

_FuncName()
Func _FuncName(\$F = True, \$L=0)
MsgBox(0, 'Level', \$L)
If Not \$F Then Return
If \$L = 5 Then \$F = False
_FuncName(\$F, \$L+1)
EndFunc

## 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

• ### Similar Content

• By gononono64
Hey there,
I'm having some issues quick-sorting my 2d array imported from a database. Im trying to sort the array based on the name that would be returned in \$array[\$n][2]. The code i posted works for smaller arrays but for some reason when i try to sort my imported array (around 9000 indexes), I get "Recursion level has been exceeded". I understand that this is maybe due to lack of returns but i couldn't find an ideal spot to stick em and again it seems to work with smaller bits of code. Could it be that 9000 is too much?
I would normally just trial and error it until i figured it out but due to the length of time to load and buffer my array it's become too time consuming. Really I'm just hoping there is a quick fix that someone with more experience happens to know.
Thank you

;;---------------------------------------------This Works---------------------------------------------------- Local \$a[7][2] = [ _ ["1", "asdfashks"], _ ["2", "SubStrlkghjing1"], _ ["3", "jdfghjsergh"], _ ["4", "nertynert"], _ ["5", "cvbncvjkrt"], _ ["6", "avbncvjkrt"], _ ["7", "oytuoyuop"]] Quicksort(\$a,1,0,6) _ArrayDisplay(\$a) ;;------------------------------------------This Does Not--------------------------------------------------------- Quicksort(\$aLargeData, 1, 0, Ubound(\$aLargeData) - 1) _ArrayDisplay(\$aLargeData) ;;----------------------------------------Quicksort Function------------------------------------------------------ Func Quicksort(ByRef \$Array, \$secondIndex, \$First, \$Last) Local \$pivot, \$i, \$j, \$temp If \$First < \$Last Then \$pivot = \$First \$i = \$First \$j = \$Last While (\$i < \$j) While (StringCompare(\$Array[\$i][\$secondIndex], \$Array[\$pivot][\$secondIndex]) <= 0) And (\$i < \$Last) \$i += 1 WEnd While (StringCompare(\$Array[\$j][\$secondIndex], \$Array[\$pivot][\$secondIndex]) > 0) \$j -= 1 WEnd If (\$i < \$j) Then _ArraySwap(\$Array, \$i, \$j) _ArraySwap(\$Array,\$pivot,\$j) Quicksort(\$Array, \$secondIndex, \$First,\$j-1) Quicksort(\$Array, \$secondIndex, \$j+1,\$Last) WEnd EndIf EndFunc
• By rm4453
How would I get this code to work? If not possible/If there is a better way... How would I do it? I can't seem to get it to work properly...

Func Go() ;Do stuff Re-Go() EndFunc Func Re-Go() Go() EndFunc
• By TheAutomator
Hi, simple question actually:
How to disable the character limit for an edit control?
Want unlimited-length (or as much as possible)
I know the GUICtrlSetLimit() function but i want to disable the limit, not set one...
Any ideas?
I thought there was some sort of autoit constant for this or something but cant find what i'm looking for.
• By Andreik
I use a DateTimePicker control and now I saw the minimum value for the year it's 1601. Know anyone how can be changed this limit?
• By Anne
Hi everyone.
I have a question and wasn't able to find any answer for this.
What is the maximum value/limit for TimerInit & TimerDiff.
I mean, If I use TimerInit() in my script, how long can it 'last'? How long will I be able to read it with TimerDiff()?
I realize that the result of TimerDiff isn't an Integer. It's a floating number and I am not sure what the maximum value is.
I would like my program to use \$Time = TimerInit() today, and then I'll be able to use TimerDiff(\$Time) tomorrow or even the day after. Is this possible? and what happens if TimerDiff exceeds the maximum value (if there is any)?
×

• Wiki

• Back

• Git