Leaderboard
Popular Content
Showing content with the highest reputation on 02/12/2016 in all areas
-
Yes, recursion in the way to handle that elegantly. I've been long ago posting a variable dump routine doing just that (and a whole lot more!). This works with beta (because Maps are supported). There is a variable compare method as well.2 points
-
Try: MsgBox(0, "Help", "Help!",0,$Gui)1 point
-
1 point
-
Since we are not in the presence of a tree structure, I do not know if this is the case to interpellate recursion. Perhaps it would be the case to use it if we were in the presence of "arrays of arrays" and we would travese even the nested arrays, but in that case recursion should be used in a different way. Here is a little variation of my draft from post #9 that can traverse not only any array regardless of array's dimensions, but also arrays of arrays (recursing in the nested arrays as well) p.s. (Since the nested loops are simply loops from 0 up to the bounds of the array dimensions stepping up by 1, I've also simplified the for-next simulator. The simulator I used in post #9 allows multiple nested loops with the step values that can be positive and/or negative mixed as needed. (since this functionality is not necessary here, I've reduced the for-next simulator for a better understanding of how it works) of course this is just a very rudimental draft , (very ugly output of data) but what is interesting for me is the concept... Local $array1[5] = ["zero","one","two","three","four"] Local $array3[2][7][2] ; populate the array just for testing For $1 = 0 to 1 for $2 = 0 To 6 For $3 = 0 to 1 $array3[$1][$2][$3] = $1 & "." & $2 & "." & $3 Next Next Next $array3[0][3][0] = $array3 ; put a nested array in a random element $array3[0][4][1] = $array1 ; put another array in a random element _ArrayTraverse($array3) ; traverse and print elements content Func _ArrayTraverse(ByRef $aMyArray) If Not IsArray($aMyArray) Then Return SetError(1, 0, -1) ; we have to know how many nested for-next loops we need ; that is one loop fro each dimension Local $iDimensions = UBound($aMyArray, 0) ; number of nested for-next loops Local $sArrayPointer = "$aMyArray" For $i = 0 to $iDimensions - 1 $sArrayPointer &= '[$aLoops[' & $i & '][2]]' Next ; ----------------------------------------------------------------------------------- ; This is a nested For-Next loops simulator with variable depth of nested loops ; pass a 2D zero based array[n][3] ; with as many records as nested loops needed ; as following: ; ; Example; For $i = start To end ; ----- --- ; [n][0] = Start value ; [n][1] = End value ; [n][2] = actual loop counter (at startup is = to Start value [n][0]) ; ; --- Initializes custom nested For-Next loops -------------------------------------- Local $aLoops[$iDimensions][3] ; nr of nested loops is $iDimensions For $i = 0 To $iDimensions - 1 $aLoops[$i][0] = 0 ; Start value $aLoops[$i][1] = UBound($aMyArray, $i + 1) - 1 ; End value $aLoops[$i][2] = $aLoops[$i][0] ; actual loop counter Next ; ----------------------------------------------------------------------------------- Local $x, $vContent Do ; =============================================================================== ConsoleWrite("Element ") For $i = 0 To UBound($aLoops) - 1 ConsoleWrite($aLoops[$i][2] & "-") Next ConsoleWrite(@TAB) $vContent = Execute($sArrayPointer) If IsArray($vContent) Then ConsoleWrite("-- here there is a Nested array --" & @CRLF) _ArrayTraverse($vContent) ; <-- recursive call for nested arrays ConsoleWrite("------------------ End of nested array" & @CRLF) Else ConsoleWrite("Contained data: " & Execute($sArrayPointer) & @CRLF) EndIf ; ------------------------------------------------------------------------------- $x = UBound($aLoops) - 1 $aLoops[$x][2] += 1 While($aLoops[$x][2] > $aLoops[$x][1]) ; check if and which nested loops are out of bound $aLoops[$x][2] = $aLoops[$x][0] ; reset the counter of this loop ($x) $x -= 1 ; check next outer nest If $x < 0 Then ExitLoop ; if we have finished all nested loops then Exit $aLoops[$x][2] += 1 ; when a deeper loop complete, increment the outer one WEnd Until $x < 0 ; If no more nested loops then exit EndFunc ;==>_ArrayTraverse1 point
-
haha one all.1 point
-
aye sir.. i just ddnt know it needd some software.. i just downloaded the autotit software and it worked. i just need to read more so i can modify the script for my self. thanks anyway hehehe1 point
-
Great! Problem solved1 point
-
In a next step check the content of the strings: For $i = 1 to StringLen($vHash) If StringMid($vHash, $i, 1) <> StringMid($sServerHash, $i, 1) Then MsgBox(0, "Error", "Strings are different at position " $i) Next1 point
-
Then check the length of the strings: If StringLen($vHash) <> StringLen($sServerHash) Then MsgBox(0, "Error", "Length is not equal!")1 point
-
I first would use VarGetTyp to check that both variables are of the same type.1 point
-
#include <Array.au3> Local $a[2][3] = [[123456,"ABCDEF",999999],["blah","ablah","bblah"]] ReDim $a[UBound($a)][4] For $i = 0 To UBound($a)-1 $a[$i][3] = $a[$i][2] $a[$i][2] = $a[$i][1] $a[$i][1] = $a[$i][0] $a[$i][0] = StringLeft($a[$i][0],3) Next _ArrayDisplay($a) edit: beat me by this much *fingers very close together*1 point
-
#include <Array.au3> Local $array1[1][3] = [[123456,"ABCDEF",999999]] Local $array2[UBound($array1)][UBound($array1, 2) + 1] For $i = 0 To UBound($array1) -1 $array2[$i][0] = StringLeft($array1[$i][0], 3) $array2[$i][1] = $array1[$i][0] $array2[$i][2] = $array1[$i][1] $array2[$i][3] = $array1[$i][2] Next _ArrayDisplay($array2)1 point
-
_GDIPlus_GraphicsDispose for an array of graphics
cabrunco reacted to InunoTaishou for a topic
You need to pass each handle to the graphics object (using the for loop). The _GDIplus_GFraphicsDispose function does this DLLCall DllCall($__g_hGDIPDll, "int", "GdipDeleteGraphics", "handle", $hGraphics) GdipDeleteGraphics takes a pointer to a graphic (your graphic object).1 point -
This is slick here...recursive, so it works with ANY array (that autoit can handle): #include <Array.au3> Local $arraya[3] Local $arrayb[3][2] Local $array1[3][3][3] Local $array2[2][4][2][3] Local $array3[2][7][2][3][4] Local $array4[2][7][2][3][4][1] ; adding this in just to test/proof $arraya[2] = 1 $arrayb[1][0] = 5 $array1[2][2][2] = "asdf" $array2[0][1][1][2] = 12341234 $array3[0][5][1][0][3] = 123465723478 $array4[1][6][1][2][3][0] = "blah" _ArrayTraverse2($arraya) _ArrayTraverse2($arrayb) _ArrayTraverse2($array1) _ArrayTraverse2($array2) _ArrayTraverse2($array3) _ArrayTraverse2($array4) Func Recursive(ByRef $a1DOutput,$aDims,$iCurrentDim,$s1DBuilderString) If $aDims[$iCurrentDim+1] Then For $i = 0 To $aDims[$iCurrentDim]-1 Recursive($a1DOutput,$aDims,$iCurrentDim+1,$s1DBuilderString & "[" & $i & "]") Next Else For $i = 0 To $aDims[$iCurrentDim]-1 $a1DOutput[0][0] = _ArrayAdd($a1DOutput, $s1DBuilderString & "[" & $i & "]") Next EndIf EndFunc Func _ArrayTraverse2(ByRef $array) If Not IsArray($array) Then ConsoleWrite("not an array" & @CRLF) Return False EndIf Local $aDims[1]=[UBound($array)] For $i = 2 To UBound($array,0) + 1 _ArrayAdd($aDims,UBound($array,$i)) Next Local $a[1][2] Recursive($a,$aDims,0,"$array") For $i = 0 To UBound($a)-1 $a[$i][1] = Execute($a[$i][0]) Next _ArrayDisplay($a) EndFunc ;==>_ArrayTraverse1 point
-
Just because...not an improvement on anything posted: #include <Array.au3> Local $arraya[3] Local $arrayb[3][2] Local $array1[3][3][3] Local $array2[2][4][2][3] Local $array3[2][7][2][3][4] Local $array4[2][7][2][3][4][1] ; adding this in just to test/proof $arraya[2] = 1 $arrayb[1][0] = 5 $array1[2][2][2] = "asdf" $array2[0][1][1][2] = 12341234 $array3[0][5][1][0][3] = 123465723478 $array4[1][6][1][2][3][0] = "blah" _ArrayTraverse($arraya) _ArrayTraverse($arrayb) _ArrayTraverse($array1) _ArrayTraverse($array2) _ArrayTraverse($array3) _ArrayTraverse($array4) Func _ArrayTraverse(ByRef $array) $iDimtions = UBound($array,0) ConsoleWrite($iDimtions & @CRLF) If $iDimtions > 5 Then ConsoleWrite("greater than 5 dims" & @CRLF) Return False EndIf Local $aDims[5]=[0,0,0,0,0] $l1DArrayUbound = 1 For $i = 1 To $iDimtions $j = UBound($array,$i) $aDims[$i-1] = $j $l1DArrayUbound = $l1DArrayUbound * $j Next ConsoleWrite($l1DArrayUbound & @CRLF) Local $a[$l1DArrayUbound] $iCount = 0 For $i = 0 To $aDims[0]-1 $s1 = "$array[" & $i & "]" $a[$iCount] = $s1 For $j = 0 To $aDims[1]-1 $s2 = $s1 & "[" & $j & "]" $a[$iCount] = $s2 For $k = 0 To $aDims[2]-1 $s3 = $s2 & "[" & $k & "]" $a[$iCount] = $s3 For $l = 0 To $aDims[3]-1 $s4 = $s3 & "[" & $l & "]" $a[$iCount] = $s4 For $m = 0 To $aDims[4]-1 $s5 = $s4 & "[" & $m & "]" $a[$iCount] = $s5 $iCount += 1 Next If $aDims[4]=0 Then $iCount += 1 Next If $aDims[3]=0 Then $iCount += 1 Next If $aDims[2]=0 Then $iCount += 1 Next If $aDims[1]=0 Then $iCount += 1 Next For $i = 0 To UBound($a)-1 ConsoleWrite($a[$i] & "=" & Execute($a[$i]) & @CRLF) Next ConsoleWrite("done" & @CRLF & @CRLF & @CRLF) _ArrayDisplay($a) EndFunc ;==>_ArrayTraverse It can be simplified into a recursive function.1 point
-
$sqlRs.open ($query,$connection) If $sqlRs.EOF = True Then Return $aHeaders Else $result = $sqlRs.GetRows If UBound($result)>0 Then _ArrayInsert($result,0,_ArrayToString($aHeaders)) Return $result $sqlRs.Close Else SetError(1) $sqlRs.Close EndIf EndIf Now that's handy. Looks sweet from a performance point of view. I might have to change my habits here, but I think it's worth. Thank you very much! On a side note, your RecordSet will never be closed if it's successful. You "Return" from the function before closing the RS: If UBound($result)>0 Then _ArrayInsert($result,0,_ArrayToString($aHeaders)) Return $result $sqlRs.Close [...]1 point
-
If the DB won't be local to user, then forget abour bare SQLite. Yet other engines can be used like PostGres, MySQL, ...1 point
-
I'm sure you knew this, but doing it directly from AutoItwithout the PowerShell and using the same algo would be: PrintBoththosesThingInAutoItWithoutUsingPowerShell() ConsoleWrite("@error = " & @error & ", @extended = " & Hex(@extended) & @CRLF) Func PrintBoththosesThingInAutoItWithoutUsingPowerShell() Local $oErrorHandler = ObjEvent("AutoIt.Error", PrintBoththosesThingInAutoItWithoutUsingPowerShell) Local $oWMIService = ObjGet("winmgmts:\\.\root\cimv2\sms") ; dot means "this comp" If @error Then Return SetError(1, @error, "") Local $oItems = $oWMIService.ExecQuery("SELECT ProductName,InstallDate,InstalledLocation,ProductVersion,UninstallString FROM SMS_InstalledSoftware") If @error Then Return SetError(2, @error, "") For $oItem In $oItems ConsoleWrite($oItem.ProductName & @CRLF) ConsoleWrite(@TAB & $oItem.InstallDate & @CRLF) ConsoleWrite(@TAB & $oItem.InstalledLocation & @CRLF) ConsoleWrite(@TAB & $oItem.ProductVersion & @CRLF) ConsoleWrite(@TAB & $oItem.UninstallString & @CRLF) ConsoleWrite(@CRLF) Next EndFunc That's why it wasn't clear to me why you used PowerShell.1 point
-
Calling phone numbers in Autoit?
PionnerCast reacted to martin for a topic
If you just want a script to dial the number and allow the converstaion to be carried on afterwards then a modem and some simple commands to the modem would be all you need. If the modem is on a COM port the udf in my signature would be able to dial for you.1 point