Modify ↓
Opened 12 years ago
Closed 12 years ago
#2564 closed Feature Request (Rejected)
UDF - _ArrayInsert - proposal
| Reported by: | mlipok | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | Standard UDFs | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description
now is
Func _ArrayInsert(ByRef $avArray, $iElement, $vValue = "") If Not IsArray($avArray) Then Return SetError(1, 0, 0) If UBound($avArray, 0) <> 1 Then Return SetError(2, 0, 0) ; Check element in array bounds + 1 If $iElement > UBound($avArray) Then Return SetError(3, 0, 0) ; Add 1 to the array Local $iUBound = UBound($avArray) + 1 ReDim $avArray[$iUBound] ; Move all entries over til the specified element For $i = $iUBound - 1 To $iElement + 1 Step -1 $avArray[$i] = $avArray[$i - 1] Next ; Add the value in the specified element $avArray[$iElement] = $vValue Return $iUBound EndFunc ;==>_ArrayInsert
proposal:
change:
; Check element in array bounds + 1 If $iElement > UBound($avArray) Then Return SetError(3, 0, 0) ; Add 1 to the array Local $iUBound = UBound($avArray) + 1 ReDim $avArray[$iUBound]
to
; Check element in array bounds + 1 Local $iUBound = UBound($avArray) If $iElement > $iUBound Then Return SetError(3, 0, 0) ; Add 1 to the array $iUBound += 1 ReDim $avArray[$iUBound]
because:
small clarification
and faster (only once uses the UBound($avArray) )
Attachments (0)
Note:
See TracTickets
for help on using tickets.

Automatic ticket cleanup.