Modify

Opened 17 years ago

Closed 16 years ago

#1118 closed Feature Request (Fixed)

Change to _ArrayConcatenate

Reported by: partypooper@… Owned by: J-Paul Mesnage
Milestone: 3.3.1.2 Component: AutoIt
Version: Severity: None
Keywords: _ArrayConcatenate Cc:

Description

I'd like to request a change to _ArrayConcatenate. Specifically, I'd like to include the ability to have a starting index for the target array. This is useful for when you don't want to include $array[0] (which sometimes contains the array size) in the resulting concatenated array.

I took the liberty of modifying the code so it could be a simple cut and paste job for the next beta release, assuming there are no errors and it doesn't break anything.

; #FUNCTION# ====================================================================================================================
; Name...........: _ArrayConcatenate
; Description ...: Concatenate two arrays.
; Syntax.........: _ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $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
;                  |3 - $avArrayTarget is not a 1 dimensional array
;                  |4 - $avArraySource is not a 1 dimensional array
;                  |5 - $avArrayTarget and $avArraySource is not a 1 dimensional array
; Author ........: Ultima
; Modified.......: Partypooper - added target start index
; Remarks .......:
; Related .......: _ArrayAdd, _ArrayPush
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource, $iStart = 0)
	If Not IsArray($avArrayTarget) Then Return SetError(1, 0, 0)
	If Not IsArray($avArraySource) Then Return SetError(2, 0, 0)
	If UBound($avArrayTarget, 0) <> 1 Then
		If UBound($avArraySource, 0) <> 1 Then Return SetError(5, 0, 0)
		Return SetError(3, 0, 0)
	EndIf
	If UBound($avArraySource, 0) <> 1 Then Return SetError(4, 0, 0)

	Local $iUBoundTarget = UBound($avArrayTarget) - $iStart, $iUBoundSource = UBound($avArraySource)
	ReDim $avArrayTarget[$iUBoundTarget + $iUBoundSource]
	For $i = $iStart To $iUBoundSource - 1
		$avArrayTarget[$iUBoundTarget + $i] = $avArraySource[$i]
	Next

	Return $iUBoundTarget + $iUBoundSource
EndFunc   ;==>_ArrayConcatenate

Attachments (0)

Change History (2)

comment:1 by TicketCleanup, 17 years ago

Version: 3.3.1.1

Automatic ticket cleanup.

comment:2 by J-Paul Mesnage, 16 years ago

Milestone: 3.3.1.2
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed in version: 3.3.1.2

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.