Modify

Opened 16 years ago

Closed 16 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 by J-Paul Mesnage, 16 years ago

Type: BugFeature Request

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

comment:2 by TicketCleanup, 16 years ago

Version: 3.3.6.1

Automatic ticket cleanup.

in reply to:  1 comment:3 by any0day@…, 16 years ago

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 by J-Paul Mesnage, 16 years ago

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

in reply to:  4 comment:5 by any0day@…, 16 years ago

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 by J-Paul Mesnage, 16 years ago

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

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

Resolution: Rejected
Status: newclosed

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()

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


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