Snippets ( AutoIt Array ): Difference between revisions
Jump to navigation
Jump to search
m (grrr) |
(Converted snippets to Template:Snippet Header) |
||
Line 1: | Line 1: | ||
__TOC__ | __TOC__ | ||
[[category:Snippets]] | [[category:Snippets]] | ||
{{Snippet Credit Header}} | {{Snippet Credit Header}} | ||
== | {{Snippet Header | ||
|UDFName=_1Dto2DArray | |||
|AuthorURL=35302-guinness | |||
|AuthorName=guinness | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
#include <Array.au3> | #include <Array.au3> | ||
Line 29: | Line 33: | ||
Return $aReturn | Return $aReturn | ||
EndFunc ;==>_1Dto2DArray | EndFunc ;==>_1Dto2DArray | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_ArrayAddEx | |||
|AuthorURL=35302-guinness | |||
|AuthorName=guinness | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
#include <Array.au3> | #include <Array.au3> | ||
Line 84: | Line 92: | ||
Return $iCount - 1 | Return $iCount - 1 | ||
EndFunc ;==>_ArrayAddEx | EndFunc ;==>_ArrayAddEx | ||
}} | |||
{{Snippet Header | |||
|UDFName=_ArrayEmpty | |||
|AuthorURL=35302-guinness | |||
|AuthorName=guinness | |||
|ReturnToTop=1 | |||
|Desc=Creates Empty 1D & 2D Array's | |||
|AutoItCode= | |||
#include <Array.au3> | #include <Array.au3> | ||
Line 113: | Line 122: | ||
EndSwitch | EndSwitch | ||
EndFunc ;==>_ArrayEmpty | EndFunc ;==>_ArrayEmpty | ||
}} | |||
{{Snippet Header | |||
|UDFName=_ArrayGet | |||
|AuthorURL=31965-progandy | |||
|AuthorName=ProgAndy | |||
|ReturnToTop=1 | |||
|Desc=Easy access for nested arrays up to 20 nested dimensions (including multidimensional arrays) | |||
|AutoItCode= | |||
Local $b[2] = ["a", "b"] | Local $b[2] = ["a", "b"] | ||
Local $a[3][2] = [[0, -1], [$b, "x"], [1, -2]] | Local $a[3][2] = [[0, -1], [$b, "x"], [1, -2]] | ||
Line 125: | Line 137: | ||
MsgBox(0, "", _ArrayGet($a, 1, 0, 1) & " # " & @error) | MsgBox(0, "", _ArrayGet($a, 1, 0, 1) & " # " & @error) | ||
; #FUNCTION# ==================================================================================================================== | ; #FUNCTION# ==================================================================================================================== | ||
Line 193: | Line 202: | ||
EndIf | EndIf | ||
EndFunc | EndFunc | ||
}} | |||
{{Snippet Header | |||
|UDFName=_ArraySet | |||
|AuthorURL=31965-progandy | |||
|AuthorName=ProgAndy | |||
|ReturnToTop=1 | |||
|Desc=Easy access for nested arrays up to 20 nested dimensions (including multidimensional arrays) | |||
|AutoItCode= | |||
Local $b[2] = ["a", "b"] | |||
Local $a[3][2] = [[0, -1], [$b, "x"], [1, -2]] | |||
Local $c[5] = [11, 22, 33, 44, 55] | |||
_ArraySet($a, $c, 1, 0, 0) | |||
; #FUNCTION# ==================================================================================================================== | ; #FUNCTION# ==================================================================================================================== | ||
Line 299: | Line 321: | ||
Case 20 | Case 20 | ||
$aArray[$i1][$i2][$i3][$i4][$i5][$i6][$i7][$i8][$i9][$i10][$i11][$i12][$i13][$i14][$i15][$i16][$i17][$i18][$i19][$i20] = $vValue | $aArray[$i1][$i2][$i3][$i4][$i5][$i6][$i7][$i8][$i9][$i10][$i11][$i12][$i13][$i14][$i15][$i16][$i17][$i18][$i19][$i20] = $vValue | ||
EndSwitch | |||
Return True | Return True | ||
EndFunc | EndFunc | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_ArrayLength | |||
|AuthorURL=35302-guinness | |||
|AuthorName=guinness | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
Local $aArray[2][50] | Local $aArray[2][50] | ||
ConsoleWrite(_ArrayLength($aArray, 2) & @CRLF) ;= > 10 - Total items | ConsoleWrite(_ArrayLength($aArray, 2) & @CRLF) ;= > 10 - Total items | ||
Line 344: | Line 370: | ||
EndSwitch | EndSwitch | ||
EndFunc ;==>_ArrayLength | EndFunc ;==>_ArrayLength | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_ArraySortNum | |||
|AuthorURL=4813-smoke-n | |||
|AuthorName=SmOke_N | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
; ArraySortNum(ByRef $nArray, $Ascending = 0, $Start = 1) | ; ArraySortNum(ByRef $nArray, $Ascending = 0, $Start = 1) | ||
; Sorts arrays based on TRUE Numerical Order, including Decimals | ; Sorts arrays based on TRUE Numerical Order, including Decimals | ||
Line 377: | Line 406: | ||
Next | Next | ||
EndFunc ;==>_ArraySortNum | EndFunc ;==>_ArraySortNum | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_AssocArray | |||
|AuthorURL=31149-milesahead | |||
|AuthorName=MilesAhead | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
; use Scripting.Dictionary object for simple associative arrays | ; use Scripting.Dictionary object for simple associative arrays | ||
; with string keys. Key comparisons are case insensitive. | ; with string keys. Key comparisons are case insensitive. | ||
Line 420: | Line 452: | ||
Return True | Return True | ||
EndFunc ;==>_AssocArrayDestroy | EndFunc ;==>_AssocArrayDestroy | ||
}} | |||
{{Snippet Header | |||
|UDFName=_FuncListToArray | |||
|AuthorURL=52-geosoft | |||
|AuthorName=GEOSoft | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
$aFlist = _FuncListToArray(@ScriptFullPath) | $aFlist = _FuncListToArray(@ScriptFullPath) | ||
If NOT @Error Then | If NOT @Error Then | ||
Line 439: | Line 474: | ||
Return SetError(1) | Return SetError(1) | ||
EndFunc | EndFunc | ||
}} | |||
{{Snippet Header | |||
|UDFName=Identify Duplicate Values In Arrays | |||
|AuthorURL=1967-garyfrost | |||
|AuthorName=GaryFrost | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
; Identify Duplicate Values In Arrays | ; Identify Duplicate Values In Arrays | ||
#include <Array.au3> | #include <Array.au3> | ||
Line 494: | Line 532: | ||
Next | Next | ||
EndFunc ;==>_FindDupe | EndFunc ;==>_FindDupe | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_Is1DArray | |||
|AuthorURL=35302-guinness | |||
|AuthorName=guinness | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
Local $sString = 'String' | Local $sString = 'String' | ||
Local $a1DArray[2] = [1, 'Row_1'] | Local $a1DArray[2] = [1, 'Row_1'] | ||
Line 510: | Line 552: | ||
Return IsArray($aArray) And (UBound($aArray, 0) = 1) | Return IsArray($aArray) And (UBound($aArray, 0) = 1) | ||
EndFunc ;==>_Is1DArray | EndFunc ;==>_Is1DArray | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_Is2DArray | |||
|AuthorURL=35302-guinness | |||
|AuthorName=guinness | |||
|ReturnToTop=1 | |||
|Desc=Check if a variable is a 2D Array. | |||
|AutoItCode= | |||
Local $sString = 'String' | Local $sString = 'String' | ||
Local $a1DArray[2] = [1, 'Row_1'] | Local $a1DArray[2] = [1, 'Row_1'] | ||
Line 527: | Line 573: | ||
Return IsArray($aArray) And (UBound($aArray, 0) = 2) | Return IsArray($aArray) And (UBound($aArray, 0) = 2) | ||
EndFunc ;==>_Is2DArray | EndFunc ;==>_Is2DArray | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_IsInBounds | |||
|AuthorURL=35302-guinness | |||
|AuthorName=guinness | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
Local $aArray[5] = ['Item_1', 'Item_2', 'Item_3', 'Item_4', 'Item_5'] | Local $aArray[5] = ['Item_1', 'Item_2', 'Item_3', 'Item_4', 'Item_5'] | ||
Line 549: | Line 598: | ||
Return $iIndex < UBound($aArray, 1) | Return $iIndex < UBound($aArray, 1) | ||
EndFunc ;==>_IsInBounds | EndFunc ;==>_IsInBounds | ||
}} | |||
== | {{Snippet Header | ||
|UDFName=_MultiFileListToArray | |||
|AuthorURL=4920-valuater | |||
|AuthorName=Valuater | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
; Multiple File List to Array | ; Multiple File List to Array | ||
Line 599: | Line 650: | ||
Return $asFileList | Return $asFileList | ||
EndFunc ;==>_MultiFileListToArray | EndFunc ;==>_MultiFileListToArray | ||
}} | |||
{{Snippet Header | |||
|UDFName=Return Min or Max Number From One or Two Arrays | |||
|AuthorURL=1967-garyfrost | |||
|AuthorName=GaryFrost | |||
|ReturnToTop=1 | |||
|AutoItCode= | |||
#include <Array.au3> | #include <Array.au3> | ||
Line 613: | Line 665: | ||
Return (0) | Return (0) | ||
EndIf | EndIf | ||
If @NumParams = 3 Then | If @NumParams = 3 Then | ||
If Not IsArray($a_nums02) Then | If Not IsArray($a_nums02) Then | ||
Line 619: | Line 672: | ||
EndIf | EndIf | ||
EndIf | EndIf | ||
Local $idx | Local $idx | ||
For $idx = 0 To UBound($a_nums01) - 1 | For $idx = 0 To UBound($a_nums01) - 1 | ||
If StringIsFloat($a_nums01[$idx]) Or StringIsInt($a_nums01[$idx]) Then | If StringIsFloat($a_nums01[$idx]) Or StringIsInt($a_nums01[$idx]) Then | ||
Line 630: | Line 683: | ||
EndIf | EndIf | ||
Next | Next | ||
_ArraySort($a_nums01, $MaxFlag) | _ArraySort($a_nums01, $MaxFlag) | ||
If @NumParams = 3 Then | If @NumParams = 3 Then | ||
For $idx = 0 To UBound($a_nums02) - 1 | For $idx = 0 To UBound($a_nums02) - 1 | ||
Line 639: | Line 694: | ||
Return (0) | Return (0) | ||
EndIf | EndIf | ||
Next | |||
_ArraySort($a_nums02, $MaxFlag) | _ArraySort($a_nums02, $MaxFlag) | ||
If $MaxFlag Then | |||
If Number($a_nums01[0]) > Number($a_nums02[0]) Then | If Number($a_nums01[0]) > Number($a_nums02[0]) Then | ||
Return $a_nums01[0] | Return $a_nums01[0] | ||
Line 655: | Line 712: | ||
EndIf | EndIf | ||
EndIf | EndIf | ||
Return $a_nums01[0] | Return $a_nums01[0] | ||
EndFunc ;==>_MinMaxa | EndFunc ;==>_MinMaxa | ||
}} |
Revision as of 16:49, 12 November 2012
Author: guinness
Author: guinness
Author: guinness
Creates Empty 1D & 2D Array's
Author: ProgAndy
Easy access for nested arrays up to 20 nested dimensions (including multidimensional arrays)
Author: ProgAndy
Easy access for nested arrays up to 20 nested dimensions (including multidimensional arrays)
Author: guinness
Author: SmOke_N
Author: MilesAhead
Author: GEOSoft
Author: GaryFrost
Author: guinness
Author: guinness
Check if a variable is a 2D Array.
Author: guinness
Author: Valuater
Author: GaryFrost