Jump to content

I Think I'm Going Crazy


Recommended Posts

I have this little piece of code. It pulls data from an webpage (this works fine) and compares it to the content of the listview. If there is already an entry like that it should increase the value, otherwise it should create a new entry.

Now when i execute the code with a debugging messagebox, everything runs fine:

Func GetInventory()
        
    Toggle_Images_Off(1)
    $o_IE = _IECreate (0)
    _IENavigate ($o_IE, "***")

    Global $InventoryContent_Name[1] = [""]
    Global $InventoryContent_Number[1] = [""]
    
    Do
        $vText = _IEBodyReadHTML($o_IE) ;Holt Seiteninhalt
        If StringLen($vText) < 400 OR StringInStr($vText, "neopets") = 0 Then _IEAction($o_IE, "refresh")
    Until StringLen($vText) >= 400
        
;Liste erstellen    
    $j = 0
    For $i = 1 To NumberOfResults($vText, $Inventory_Startstring_Items)
        $vTemp = 0
        $vItem = SucheBegriff($vText, $i, $Inventory_Startstring_Items, $Inventory_Endstring_Items)

        While NOT $j <= 0
            $vTest = _GUICtrlListViewGetItemText($Inventory_Listview, ($j-1), 0)
            If  $vTest = $vItem Then;Item vorhanden
                MsgBox(0, "", "")
                _GUICtrlListViewSetItemText($Inventory_Listview, ($j-1), 1, (_GUICtrlListViewGetItemText($Inventory_Listview, ($j-1), 1)+1))
                $vTemp = 1
            EndIf
            $j = $j - 1
        WEnd
        If $vTemp = 0 Then
            GUICtrlCreateListViewItem ($vItem & "|1", $Inventory_Listview)
        EndIf
        $j = _GUICtrlListViewGetItemCount($Inventory_Listview)
;~      Sleep(2000)
        MsgBox(0, "Listenlänge", $j)
    Next
        
Toggle_Images_Off(0)
_IEAction($o_IE, "quit")

EndFunc

Posted Image

If I remove the Msgbox and insert a sleep command (to make sure it's not an timing issue) the comparison seems to fail.

Posted Image

Could anyone point me in the right direction? I'm somewhat stumped here :think:

Thanks.

Link to comment
Share on other sites

Added "MyGUI" to the _GUICtrlListViewGetItemText. No changes so far.

I can't see a place to add a windowtitle to the _GUICtrlListViewSetItemText

function though.

The only modifiers listed in the helpfile are "$h_listview, $i_index, $i_subitem, $s_text"

Thanks again for your time.

Link to comment
Share on other sites

Hmm - this was a tad too hasty. :think:

Argh, how stupid can one person be ???

_GUICtrlListViewSetItemText expects a string.

For future boneheads: a simple

$Value = String((_GUICtrlListViewGetItemText($Inventory_Listview, ($j-1), 1))+1)

_GUICtrlListViewSetItemText($Inventory_Listview, ($j-1), 1, $Value)

did the trick. Thanks again to everyone.

<shakes head> reading can be SO hard sometimes crying.gif

I seem to have narrowed it down a bit. Seems, the error occurs when the GUI does not have focus.

Is there any way around this? The initial data query can take up to 4 minutes. It seems to be somewhat sloppy to have the users stare at the screen during this just to avoid losing focus. :(

Link to comment
Share on other sites

Func GetInventory()
        
    Toggle_Images_Off(1)
    $o_IE = _IECreate (0)
    _IENavigate ($o_IE, "***")

    Global $InventoryContent_Name[1] = [""]
    Global $InventoryContent_Number[1] = [""]
    
    Do
        $vText = _IEBodyReadHTML($o_IE)   ;Holt Seiteninhalt
        If StringLen($vText) < 400 OR StringInStr($vText, "neopets") = 0 Then _IEAction($o_IE, "refresh")
    Until StringLen($vText) >= 400
        
;Liste erstellen    
    $j = 0
    For $i = 1 To NumberOfResults($vText, $Inventory_Startstring_Items)
        $vTemp = 0
        $vItem = SucheBegriff($vText, $i, $Inventory_Startstring_Items, $Inventory_Endstring_Items)

        While NOT $j <= 0
            $vTest = _GUICtrlListViewGetItemText($Inventory_Listview, ($j-1), 0, "MyGUI")
            If  $vTest = $vItem Then;Item vorhanden
                MsgBox(0, "", "")
                _GUICtrlListViewSetItemText($Inventory_Listview, ($j-1), 1, (_GUICtrlListViewGetItemText($Inventory_Listview, ($j-1), 1, "MyGUI")+1))
                $vTemp = 1
            EndIf
            $j = $j - 1
        WEnd
        If $vTemp = 0 Then
            GUICtrlCreateListViewItem ($vItem & "|1", $Inventory_Listview)
        EndIf
        $j = _GUICtrlListViewGetItemCount($Inventory_Listview)
;~       Sleep(2000)
        MsgBox(0, "Listenlänge", $j)
    Next
        
Toggle_Images_Off(0)
_IEAction($o_IE, "quit")

EndFunc

Try this?

#)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...