Modify

Opened 15 years ago

Closed 14 years ago

#1602 closed Feature Request (Rejected)

_ArrayMinIndex and Void entries

Reported by: any0day@… Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: _ArrayMinIndex Cc:

Description

Thought I would just point out that for void entries, when calling _ArrayMinIndex, it always returns those entries. I was expecting it to throw an error if void entries were detected. As a result, I added a bit of code to the function so I could catch this:

; Search
     If $iCompNumeric Then
         For $i = $iStart To $iEnd
             If $avArray[$i] = Chr(0) Then Return SetError(4, 0, -1)
             If Number($avArray[$iMinIndex]) > Number($avArray[$i]) Then $iMinIndex = $i
         Next
     Else
         For $i = $iStart To $iEnd
             If $avArray[$i] = Chr(0) Then Return SetError(4, 0, -1)
             If $avArray[$iMinIndex] > $avArray[$i] Then $iMinIndex = $i
         Next
     EndIf

A minor addition, but one I found to be helpful. It is, however, up to you on how you want to handle it.

Attachments (0)

Change History (7)

comment:1 follow-up: Changed 15 years ago by Jpm

  • Type changed from Bug to Feature Request

for me it is not a bug as Autoit do implicit conversion.
I move it to "feature request"

comment:2 Changed 15 years ago by TicketCleanup

  • Version 3.3.6.1 deleted

Automatic ticket cleanup.

comment:3 in reply to: ↑ 1 Changed 15 years ago by any0day@…

Replying to Jpm:

for me it is not a bug as Autoit do implicit conversion.
I move it to "feature request"

The issue is that sometimes if there are void entries, this can cause a program crash because _ArrayMin uses the min index as the subscript. Error output will catch this, stopping the crash. This is why I labeled bug, and not feature.

comment:4 follow-up: Changed 15 years ago by Jpm

Why a program can crash just the return an "void" entry?
give me a good example of such crash

comment:5 in reply to: ↑ 4 Changed 15 years ago by any0day@…

Replying to Jpm:

Here's a simplified example:

While $i <= 10
	$array[$i] = $i
	ToolTip("Lowest Value = " & _ArrayMin($array), 0,0)
WEnd

Related Functions _ArrayMinIndex, _ArrayMaxIndex, _ArrayMin, _ArrayMax.

Reason: Subscript Out Of Bounds

Related Example:

Func _ArrayMin(Const ByRef $avArray, $iCompNumeric = 0, $iStart = 0, $iEnd = 0)
	Local $iResult = _ArrayMinIndex($avArray, $iCompNumeric, $iStart, $iEnd)
	If @error Then Return SetError(@error, 0, "")
	'''Return $avArray[$iResult]'''
EndFunc   ;==>_ArrayMin

Bolded reasons.

Fix: add an error return on _ArrayMinIndex and _ArrayMaxIndex stated above.

comment:6 Changed 15 years ago by Jpm

It is over simplified as $array is not declared and $i not set too
can you put a real crashing example
Thanks

comment:7 Changed 14 years ago by Jpm

  • Resolution set to Rejected
  • Status changed from new to closed

I cannot imagine a real crash but just the script not working as you want.
If you really need to get error on such entries just check them before calling _ArrayMinIndex()

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 ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.