Jump to content
  1. iamtheky

    iamtheky

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By algiuxas
      Hello everybody, so I might found a bug in _ArraySearch:
       
      #include <Array.au3> Local $abc[2] = ["b", "b"] $h = "+---------------------------------+" & @CRLF ConsoleWrite($h) For $i = 0 To 1 $abc[0] = 0 out() $abc[0] = 1 out() $abc[0] = -1 out() $abc[0] = "Abc" out() $abc[1] = "Hello" Next Func txt() Return "$abc = [" & $abc[0] & ", " & $abc[1] & "]" & @CRLF & _ "> _ArraySearch($abc,""Hello"") = " EndFunc ;==>txt Func shouldoutput($ans) Return "_ArraySearch Should return: " & ($ans ? 1 : -1) EndFunc ;==>shouldoutput Func out() ConsoleWrite("> " & txt() & _ArraySearch($abc, "Hello") & @CRLF & "> " & shouldoutput($abc[1] == "Hello") & @CRLF & $h) EndFunc ;==>out Exit Sorry for this messy script
    • By rootx
      . THX
      I should use _arraysearch or there is another function to be used?
      #include <Array.au3> #include <File.au3> Global Const $sFilePath = @ScriptDir&"\1.txt",$sFilePath2= @ScriptDir&"\2.txt" FileOpen($sFilePath,$FO_OVERWRITE) For $x = 1 to 10 FileWriteLine($sFilePath,$x&"test") Next FileClose($sFilePath) FileOpen($sFilePath2,$FO_OVERWRITE) For $x2 = 1 to 5 FileWriteLine($sFilePath2,$x2&"test") Next FileClose($sFilePath2) Local $aRetArray,$aRetArray2 $aArray = _FileReadToArray($sFilePath,$aRetArray) $aArray2 = _FileReadToArray($sFilePath2,$aRetArray2) If UBound($aRetArray) > UBound($aRetArray2) Then For $s = 1 To UBound($aRetArray) - 1 $search = _ArraySearch($aRetArray2, $aRetArray[$s]) If @error = 6 Then MsgBox(48, "Attention", $aRetArray[$s] & " was not found!!!") EndIf Next EndIf  
    • By Shane0000
      Local $aArray_1[3] = [0,'x',2] $a1 = Execute('$aArray_' & 1 ) If @error Then Msgbox(0,@error,'Execute not working') _ArrayDisplay($a1) $i1 = _ArraySearch($a1,'y') If @error Then Msgbox(0,@error,'not working - 0') ConsoleWrite('$i1: ' & $i1 & @CRLF) $i1 = _ArraySearch($a1,'x') If @error Then Msgbox(0,@error,'not working - 1') ConsoleWrite('$i1: ' & $i1 & @CRLF) $i1 = _ArraySearch($aArray_1,'y') If @error Then Msgbox(0,@error,'not working - 2') ConsoleWrite('$i1: ' & $i1 & @CRLF) $i1 = _ArraySearch($aArray_1,'x') If @error Then Msgbox(0,@error,'not working - 3') ConsoleWrite('$i1: ' & $i1 & @CRLF) Im not sure what is going on in the above example. _ArraySearch should return a -1 if the item searched for is not found, however :
      _ArraySearch returns a 0 when searching for 'y' in the above array. [0,'x',2]
      _ArraySearch returns a 0 when searching for 'x' even tho 'x' resides in row 1
      Also referencing the $aArray_1 variable returns the same 0 from _ArraySearch both times.
      No @error codes are set off either.
      What am I missing here ? Thanks 
×
×
  • Create New...