Jump to content
Sign in to follow this  
Gaviel

String Parse

Recommended Posts

which variable obtain the output ?! I tried

MsgBox(64, "Result", "VanBlattidCat = " & $bolRET)

But it didn't display output ..

Sorry I'm new to this ..

Edited by Gaviel

Share this post


Link to post
Share on other sites

That $bolRET is LOCAL inside the function, so you don't see it outside the function. In my demo, the return value of the function is still stored in and displayed from $RET.


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

so you mean it should look like this ?!

$RET = _TestDiv("VanBlattidCat")
MsgBox(64, "Result", "VanBlattidCat = " & $RET)
Func _TestDiv($sSearch)
    Local $bolRET = False, $iErr = 1
    $colDiv = _IETagNameGetCollection($oIE, "DIV")
    For $oDiv In $colDiv
        If StringInStr(_IEPropertyGet($oDiv, "innerText"), $sSearch) Then
            $iErr = 0
            $oSib = $oDiv.nextSibling
            If IsObj($oSib) And $oSib.className & "" = "ldetails" Then
                $bolRET = True
                ExitLoop
            EndIf
        EndIf
    Next
    Return SetError($iErr, 0, $bolRET)
EndFunc   ;==>_TestDiv

EDIT : Tried that but instead of an ERROR .. The script return a FALSE ..

The script should return ERROR cause 'VanBlattidCat' doesn't exist in the HTML code ..

what could be the problem !?

Edited by Gaviel

Share this post


Link to post
Share on other sites

When the initial search string is not found the @error macro is set, not an "ERROR" string. You would test it this way:

$sSearch = "VanBlattidCat"
$RET = _TestDiv($sSearch)
MsgBox(64, "Result", "Searched for: " & $sSearch & @CRLF & _
        "$RET = " & $RET & @CRLF & _
        "@error = " & @error)

Func _TestDiv($sSearch)
    Local $bolRET = False, $iErr = 1
    $colDiv = _IETagNameGetCollection($oIE, "DIV")
    For $oDiv In $colDiv
        If StringInStr(_IEPropertyGet($oDiv, "innerText"), $sSearch) Then
            $iErr = 0
            $oSib = $oDiv.nextSibling
            If IsObj($oSib) And $oSib.className & "" = "ldetails" Then
                $bolRET = True
                ExitLoop
            EndIf
        EndIf
    Next
    Return SetError($iErr, 0, $bolRET)
EndFunc   ;==>_TestDiv

You might also use the "If Not @error" example previously given. The contents of $RET (True/False) tell you if the total conditions were met, while the status of @error (0/1) tells you if failed to find the search string at all.

You really need to get a grip on this, as most AutoIt functions use the @error macro to report various conditions, so you WILL see this again.

;)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...