Modify

Opened 15 years ago

Closed 14 years ago

#1118 closed Feature Request (Fixed)

Change to _ArrayConcatenate

Reported by: partypooper@… Owned by: Jpm
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 Changed 15 years ago by TicketCleanup

  • Version 3.3.1.1 deleted

Automatic ticket cleanup.

comment:2 Changed 14 years ago by Jpm

  • Milestone set to 3.3.1.2
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed in version: 3.3.1.2

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.