Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#1569 closed Feature Request (Completed)

_ArraySearch fails returns wrong result

Reported by: david@… Owned by: Jpm
Milestone: 3.3.7.0 Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

If one has an array with the first element having a 0 value then ArraySearch always returns 0 matching whatever you are looking for as 0.

#include <Array.au3>
Dim $ArrayWorks[2]=["0","String"]
Dim $ArrayFails[2]=[0,"String"]
MsgBox( 0, _ArraySearch( $ArrayWorks, "String" ), _ArraySearch( $ArrayFails, "String" ) )

Attachments (1)

ArraySearchBugRepro.au3 (181 bytes) - added by david@… 9 years ago.

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by david@…

comment:1 Changed 9 years ago by anonymous

I have since found the bug report #1142 which is the exact same which was classified as not a bug because the string is converted to a Number prior to compare which makes the search successful.

I am not sure if the data should be converted prior to comparison as perhaps the string "0" should not equal to the integer 0.

Perhaps if the documentation had some statement indicating that the search string will be converted to match each array's element that would help clarify what is going on.

comment:2 Changed 9 years ago by Jpm

  • Type changed from Bug to Feature Request

I prefer to treat it as a request feature and to add a mode that will strictly match if the variable type are the same.

The checking of the variables in AutoIt is kept with this new mode.
I don't like too much "string" = 0 or "" = 0 but that's the way AutoIt is doing comparison priority to numbers ... So I cannot change the default value.

comment:3 Changed 9 years ago by Jpm

  • Milestone set to 3.3.7.0
  • Owner set to Jpm
  • Resolution set to Completed
  • Status changed from new to closed

Added by revision [5854] in version: 3.3.7.0

comment:4 Changed 9 years ago by TicketCleanup

  • Version 3.3.6.1 deleted

Automatic ticket cleanup.

comment:5 Changed 9 years ago by Spiff59

Isn;t all you'd need to add is this one line near the top of the _ArraySearch() function?
If $vValue == 0 Or $vValue == "" Then $iCase = 1

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.