Search the Community
Showing results for tags 'recursion'.
-
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
-
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
-
Is there a way to increase max recursion level? For example this code is using recursion to fill an area with a color but the job is interrupted because of reaching the recursion limit! #include <GDIPlus.au3> $sRegPath = "HKLM\SOFTWARE\AutoIt v3\AutoIt" If StringInStr("X64IA64", @OSArch) Then $sRegPath = StringReplace($sRegPath, "SOFTWARE", "SOFTWARE\Wow6432Node") _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif") $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate("Test", $iW, $iH) GUISetState() $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) AdlibRegister("UpdateView", 10) $iColor2Fill = 0xFFFFFFFF ;~ _GDIPlus_FloodFillRec($hImage, 0, 0, 0xFF000080, 0xFFFFFF00) _GDIPlus_FloodFillRec($hImage, 82, 24, 0xFF000080, 0xFFFFFF00) _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Filled.png") ;~ ShellExecute(@ScriptDir & "\Filled.png") AdlibUnRegister("UpdateView") ConsoleWrite("Done" & @LF) Do Until GUIGetMsg() = -3 _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() Exit Func _GDIPlus_FloodFillRec(ByRef $hBitmap, $iX, $iY, $iColorOld, $iColorNew) ;coded by UEZ 2013-01-12 Local Static $iRec = 1 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 Local $iRecLimit = 3899 $aResult = DllCall($ghGDIPDll, "uint", "GdipGetImageDimension", "handle", $hBitmap, "float*", 0, "float*", 0) If ($iX + 1) < $aResult[2] + 1 Then $iRec += 1 If $iRec = $iRecLimit Then Return -1 _GDIPlus_FloodFillRec($hBitmap, $iX + 1, $iY, $iColorOld, $iColorNew) ;go east $iRec -= 1 EndIf If ($iY + 1) < $aResult[3] + 1 Then $iRec += 1 If $iRec = $iRecLimit Then Return -1 _GDIPlus_FloodFillRec($hBitmap, $iX, $iY + 1, $iColorOld, $iColorNew) ;go south $iRec -= 1 EndIf If ($iX - 1) > -1 Then $iRec += 1 If $iRec = $iRecLimit Then Return -1 _GDIPlus_FloodFillRec($hBitmap, $iX - 1, $iY, $iColorOld, $iColorNew) ;go west $iRec -= 1 EndIf If ($iY - 1) > -1 Then $iRec += 1 If $iRec = $iRecLimit Then Return -1 _GDIPlus_FloodFillRec($hBitmap, $iX, $iY - 1, $iColorOld, $iColorNew) ;go north $iRec -= 1 EndIf Return 1 EndFunc ;==>_GDIPlus_FloodFillRec Func UpdateView() _GDIPlus_GraphicsDrawImage($hGfx, $hImage, 0, 0) EndFunc Br, UEZ
-
A Quine is a program that can output it's own source without having direct access or user intervention. (This Means no reading of the script file, prompting for source input, packaging the source, or using inbuilt source references) A Quine is not necessarily malicious or self-duplicating, but rather an attempt at a theory. Definition of Quine Why torture ourselves making this this way? The reason is to [re]prove a concept of computing: that it is possible for a turing-complete language to output it's own source-code. (or optionally, output a program in another language that outputs the original source code; aka. a multiquine ) Here, are some AutoIt3 Quines: My Quines: One-line quines from my reply on Page 2: ConsoleWrite(StringReplace("ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"ConsoleWrite(StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))MsgBox(0,'',StringReplace("MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))",'%'&'s',Chr(34)&"MsgBox(0,'',StringReplace(%s,'%'&'s',Chr(34)&%s&Chr(34)))"&Chr(34)))Old 2-Line Quine: $x="$x=%srnMsgBox(0,'Quine Example',StringFormat($x,Chr(34)&$x&Chr(34)))" MsgBox(0,'Quine Example',StringFormat($x,Chr(34)&$x&Chr(34)))Skeleton/Customizable Quine (Page 2) Global $gsQuine eq("MsgBox(0,'program','first exec line')") eq("MsgBox(0,'program','second exec line')") Func eq($s) Execute($s) $gsQuine&=BinaryToString(0x22287165)&$s&BinaryToString(0x0A0D2922) EndFunc $x="Global $gsQuinern%sFunc eq($s)rnExecute($s)rn$gsQuine&=BinaryToString(0x22287165)&$s&BinaryToString(0x0A0D2922)rnEndFuncrn$x=%srnMsgBox(0,'Quine Example',StringFormat($x,$gsQuine,Chr(34)&$x&Chr(34)))" MsgBox(0,'Quine Example',StringFormat($x,$gsQuine,Chr(34)&$x&Chr(34))) Any Questions? Quines by Michel Claveau: $x="MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x)" MsgBox(0,'Quine','$x='&chr(34)&$x&chr(34)&@CRLF&$x) $g=chr(34) $x="MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x)" MsgBox(0,'Q','$g=chr(34)'&@CRLF&'$x='&$g&$x&$g&@CRLF&$x) Images of past quines: - - - And for my next magic trick - an AutoIt3 / PHP Polyglot (non-quine and all too simple) A Polyglot is a script that can perform the same actions in multiple languages without manipulation of the code. ;=- <?php ;/* ConsoleWrite(";=- Hello World -=;"); ;*/ ; echo "Hello World"; ; ?> -=;In either language, this outputs ";=- Hello World -=;" to the console.
-
Just thinking/working on some source code recursion scanner. (nothing fancy, just a basic potential problem locator/scanner) But I'm kinda at a loss at finding a nice or good way go about is. Steps that passed my mind. - Find all function(definitions) names. [working] - Get hold of function code. (from full source) [working] - Scan function code for calls to other function. [initial scan: working] At this point I got array(s) with: - User-function(def) names. - User-function(unique) call count from that function. (+names of those calls) Here is where I kinda run out of ideas. Probably just need some more time to come up with something ...