Sign in to follow this  
Followers 0
igotandrew

is there goto in autoit?

11 posts in this topic

Or something like it?

In vb6/vbs

you could've easily done

Function XX(Params as variables)

while

if conditional statement = true then

goto cd

end if

wend

cd:

end function

Share this post


Link to post
Share on other sites



Then any thoughts on how I'd go up on this?

I'm working on a spider / web crawler

So

While 1 (makes it go on forever)

If page src contains (compare to list of words via text file) then exit loop, go to new web page

Otherwise do stuff

Wend

Share this post


Link to post
Share on other sites

I don't want to stop the web crawling permanently, I just want it to move on.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Func P()
    While 1
        _IENavigate($oIE, "webpage" & $vID)
        
        $oSrc = _IEBodyReadText($oIE)
        
        For $i = 1 to $B[0]
            If StringInStr($oSrc, $B[$i], 2) > 0 Then;something detected
                L("Encountered blacklisted site '" & $B[$i] & "', skipping. URL: " & $vID)
            EndIf
        Next
; do junk

$vID = $vID + 2
    WEnd
EndFunc

And $B is an array holding websites (it's entries are irrelevant, and are from a text file (split))

It should exit where it says "encountered black listed site"

I'm thinking of moving the $vID = $vID +2 to the front, I'm not really 100% sure what to do.

Edited by igotandrew

Share this post


Link to post
Share on other sites

To exit the for-next loop when the IF is true you just add the ExitLoop after line containing the L(...).

This will stop the for next loop but will stay within the While-Wend loop

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Is there a way to bypass the "do stuff" if something is detected in the for loop?

Share this post


Link to post
Share on other sites

I'm an idiot.

After thinking about this logicailly for a few minutes, I came to the answer.

Thanks.

Share this post


Link to post
Share on other sites

There are many, many was to handle that

Func P()
    Local $pass
    
    While 1
        $pass = ""
        _IENavigate($oIE, "webpage" & $vID)

        $oSrc = _IEBodyReadText($oIE)

        For $i = 1 To $B[0]
            If StringInStr($oSrc, $B[$i], 2) > 0 Then;something detected
                ;L("Encountered blacklisted site '" & $B[$i] & "', skipping. URL: " & $vID)
                $pass = 1
            EndIf
        Next
        
        If $pass = "" Then
            ; do junk
        EndIf
        
        $vID = $vID + 2
    WEnd
EndFunc   ;==>P

8)


NEWHeader1.png

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  
Followers 0