Ebenezer Posted March 20, 2006 Share Posted March 20, 2006 Hi everyone. First post so please be gentle Running the following script should create a list of the 10 shops listed on a webpage. Obviously it should not include multiple mentions of the same shop on different pages. I use the _arraysearch function to exclude already existing shopnamesHowever occasionally the _Arraysearch function returns an empty string despite the searchterm being found. I inserted a debugging Msgbox in the _arraysearch routine:MsgBox(0, "Test", "Gesucht" & " = " & $vWhat2Find & " -- Gefunden = " & $avArray[$iCurrentPos] & " Ergebnis = " & $Ergebnis)with the following results:As you can see the working match gives only one endresult while the other returns two. I have no idea why this occurs, nor have i been able to consistently reproduce it. It occurs seemingly randomly at different positions in the array.Any help would be appreciated $Namensvergleich = _ArraySearch($NameArray, $Neuer_Name, "", "", 1) If $Namensvergleich = "" Then ;Name noch nicht vorhanden -> Bearbeiten For $i = 0 To 9 Step 1 If $Neuer_Preis < $PreisArray[$i] Then _ArrayInsert($PreisArray, $i, $Neuer_Preis);Neuer Eintrag, wenn besserer Preis _ArrayInsert($AnzahlArray, $i, $Neue_Anzahl) _ArrayInsert($NameArray, $i, $Neuer_Name) _ArrayPop($PreisArray) ;Alter Höchstwert raus _ArrayPop($NameArray) _ArrayPop($AnzahlArray) ExitLoop EndIf Next EndIf Link to comment Share on other sites More sharing options...
jefhal Posted March 20, 2006 Share Posted March 20, 2006 MsgBox(0, "Test", "Gesucht" & " = " & $vWhat2Find & " -- Gefunden = " & $avArray[$iCurrentPos] & " Ergebnis = " & $Ergebnis) $Namensvergleich = _ArraySearch($NameArray, $Neuer_Name, "", "", 1) If $Namensvergleich = "" Then;Name noch nicht vorhanden -> Bearbeiten For $i = 0 To 9 Step 1 If $Neuer_Preis < $PreisArray[$i] Then _ArrayInsert($PreisArray, $i, $Neuer_Preis);Neuer Eintrag, wenn besserer Preis _ArrayInsert($AnzahlArray, $i, $Neue_Anzahl) _ArrayInsert($NameArray, $i, $Neuer_Name) _ArrayPop($PreisArray) ;Alter Höchstwert raus _ArrayPop($NameArray) _ArrayPop($AnzahlArray) ExitLoop EndIf Next EndIfI don't see how the msgbox code ties in with the second code sample. Is it possible to send enough code for us to test the entire example ourselves? ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Ebenezer Posted March 20, 2006 Author Share Posted March 20, 2006 I don't see how the msgbox code ties in with the second code sample. Is it possible to send enough code for us to test the entire example ourselves? Hi, thanks for looking at this. The whole code probably wouldn't be helpful since it queries a member page that requires my login. I included it anyway I will add the complete function code below. The function gets called as XterSuchlauf($Text) with the complete source of the queried webpage obtained by an $Text = _IEBodyReadHTML($o_IE) command. The msgbox code was added to the _arraysearch function in the standard Array.au3 library as follows, to narrow down the place where the error occurs. As you can see in the second screenie it should report the position in the array where the searchterm matches the arraycontent. However it seems to return "" even though the search term matches expandcollapse popupFunc _ArraySearch($avArray, $vWhat2Find, $iStart = 0, $iEnd = 0, $iCaseSense = 0) Local $iCurrentPos, $iUBound ;~ MsgBox(0, "Arraysearch called", "") $Ergebnis = 0 If Not IsArray($avArray) Then SetError(1) Return "" EndIf $iUBound = UBound($avArray) - 1 If $iEnd = 0 Then $iEnd = $iUBound If $iStart > $iUBound Then SetError(2) Return "" EndIf If $iEnd > $iUBound Then SetError(3) Return "" EndIf If $iStart > $iEnd Then SetError(4) Return "" EndIf If Not ($iCaseSense = 0 Or $iCaseSense = 1) Then SetError(5) Return "" EndIf For $iCurrentPos = $iStart To $iEnd ;~ MsgBox(0, "For ... Next called", "") Select Case $iCaseSense = 0 ;~ MsgBox(0, "Case 0 called", "") If $avArray[$iCurrentPos] = $vWhat2Find Then SetError(0) $Ergebnis = $iCurrentPos ,3 Return $iCurrentPos EndIf Case $iCaseSense = 1 ;~ MsgBox(0, "Case 1 called", "") If $avArray[$iCurrentPos] == $vWhat2Find Then SetError(0) $Ergebnis = $iCurrentPos MsgBox(0, "Test", "Gesucht" & " = " & $vWhat2Find & " -- Gefunden = " & $avArray[$iCurrentPos] & " Ergebnis = " & $Ergebnis) Return $iCurrentPos EndIf EndSelect If $Ergebnis <> 0 Then MsgBox(0, "Übereinstimmung gefunden zwischen", $vWhat2Find & " --- " & $Ergebnis & " --- " & $avArray[$iCurrentPos]) Next SetError(0) Return "" EndFunc ;==>_ArraySearch expandcollapse popupFunc XterSuchlauf($Searchedstring_Temp) $Zaehler = 0 If NumberOfResultsWizard($Searchedstring_Temp) < 10 Then $Gewuenschte_Ergebnisse = NumberOfResultsWizard($Searchedstring_Temp) Else $Gewuenschte_Ergebnisse = 10 EndIf While $Zaehler < $Gewuenschte_Ergebnisse $Neuer_Name = Sucheperson($Searchedstring_Temp, $Zaehler+1) ;~ MsgBox(1, "Neuer Name", $Neuer_Name) $Neuer_Preis = Suchepreis($Searchedstring_Temp, $Zaehler+1);Neuen Preis suchen $Neue_Anzahl = Sucheanzahl($Searchedstring_Temp, $Zaehler+1);Neue Menge suchen $Zaehler = $Zaehler+1 $Namensvergleich = _ArraySearch($NameArray, $Neuer_Name, "", "", 1) MsgBox(1, "Namenvergleich", "Ergebnis $Namensvergleich = " & $Namensvergleich) If $Namensvergleich = "" Then ;Name noch nicht vorhanden -> Bearbeiten ;~ MsgBox For $i = 0 To 9 Step 1 If $Neuer_Preis < $PreisArray[$i] Then _ArrayInsert($PreisArray, $i, $Neuer_Preis) ;Neuer Eintrag, wenn besserer Preis _ArrayInsert($AnzahlArray, $i, $Neue_Anzahl) _ArrayInsert($NameArray, $i, $Neuer_Name) _ArrayPop($PreisArray) ;Alter Höchstwert raus _ArrayPop($NameArray) _ArrayPop($AnzahlArray) ;Hier sollte noch eine Routine hin, die die Menge der Ergebnisse unter Menge 10 hält ExitLoop EndIf Next EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
Ebenezer Posted March 20, 2006 Author Share Posted March 20, 2006 Thanks to all who tried to help. The error was in the equation.If $Namensvergleich = "" ThenIt seems that Autoit considers "" = 0. So when _Arraysearch found an matching entry at Array[0] the equation simply ignored the result. If I do 0 == "" ---> ie make the equation case-sensitive, it works fine.Hope this clarification might help another beginner. Link to comment Share on other sites More sharing options...
Ebenezer Posted March 20, 2006 Author Share Posted March 20, 2006 Examplescript $1 = "" $2 = 0 If $1 = $2 Then MsgBox(0, "Test", "0 = _") If NOT ($1 == $2) Then MsgBox(0, "Test", "0 NOT == _") Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now