Nhardel Posted February 19, 2009 Share Posted February 19, 2009 (edited) Im sure this is easy for some of the more advanced users in here. But one of my biggest issue with most of the array stuff is that it is built for 1d arrays only. Most of the arrays I use are 2d or are 2d by the time I get all the info I need. Anyway thought this might help some people that are still in the learning and medium levels of Autoit programing. I plan on releasing more as I need it or requested. The code will always resize the target array to the bigger of the target and source arrays. expandcollapse popup; #FUNCTION# ==================================================================================================== ================ ; Name...........: _ArrayConcatenate2d ; Description ...: Concatenate two 2d arrays ; Syntax.........: _ArrayConcatenate ( $avArrayTarget, $avArraySource ) ; Parameters ....: $avArrayTarget - The array to concatenate onto ; $avArraySource - The array to concatenate from ; Return values .: Success - $avArrayTarget's new size ; Failure - 0, sets @error to: ; |1 - $avArrayTarget is not an array ; |2 - $avArraySource is not an array ; Author ........: Ultima ; Modified.......: Nhardel ; Remarks .......: ; Related .......: _ArrayAdd, _ArrayPush ; Link ..........; ; Example .......; no ; ==================================================================================================== =========================== Func _ArrayConcatenate2d(ByRef $avArrayTarget, Const ByRef $avArraySource) If Not IsArray($avArrayTarget) Then Return SetError(1, 0, 0) If Not IsArray($avArraySource) Then Return SetError(2, 0, 0) Local $xUBoundTarget = UBound($avArrayTarget), $xUBoundSource = UBound($avArraySource) if Ubound($avArrayTarget,2) <= Ubound($avArraySource,2) Then $yUBoundTarget = Ubound($avArraySource,2) Else $yUBoundTarget = Ubound($avArrayTarget,2) EndIf ReDim $avArrayTarget[$xUBoundTarget + $xUBoundSource][$yUBoundTarget] For $h = 0 to $yUBoundTarget-1 For $i = 0 To $xUBoundSource - 1 $avArrayTarget[$xUBoundTarget + $i][$h] = $avArraySource[$i][$h] Next Next Return $avArrayTarget EndFunc;==>_ArrayConcatenate Edited January 19, 2011 by nhardel Link to comment Share on other sites More sharing options...
WideBoyDixon Posted February 19, 2009 Share Posted February 19, 2009 I think you have some typos in there. You're mixing your $x... with your $i...: (29,41) : WARNING: $iUBoundTarget: possibly used before declaration. ReDim $avArrayTarget[$iUBoundTarget + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ (29,57) : WARNING: $iUBoundSource: possibly used before declaration. ReDim $avArrayTarget[$iUBoundTarget + $iUBoundSource] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Nhardel Posted February 19, 2009 Author Share Posted February 19, 2009 I think you have some typos in there. You're mixing your $x... with your $i...: (29,41) : WARNING: $iUBoundTarget: possibly used before declaration. ReDim $avArrayTarget[$iUBoundTarget + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ (29,57) : WARNING: $iUBoundSource: possibly used before declaration. ReDim $avArrayTarget[$iUBoundTarget + $iUBoundSource] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ WBD Sorry It has been fixed Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now