Jump to content

noob need help by loop


swa
 Share

Recommended Posts

hi

soory my englisch is not so good ...

but i hope you can understand me

okay i have this code

$oFrame = _IEFrameGetObjByName ($oIE1, "up")
$sHTML = _IEDocReadHTML ($oFrame)
$result = StringLeft($shtml, 18)

If $result = "<HTML><HEAD><Meta" Then 
sleep(2*1000)
else
$link=FileReadLine ("bannerlinks.txt", $i )
_IENavigate ($oIE1, $link)
    $i = $i + 1
EndIF
Sleep(2 * 1000)
$oFrame = _IEFrameGetObjByName ($oIE2, "up")
$sHTML = _IEDocReadHTML ($oFrame)
$result = StringLeft($shtml, 18)

If $result = "<HTML><HEAD><Meta" Then 
sleep(2*1000)
else
$link=FileReadLine ("bannerlinks.txt", $i )
_IENavigate ($oIE2, $link)
    $i = $i + 1
EndIF
Sleep(2 * 1000)

is there a way to have this only one time ?

i hope somebody understand me ...

swa

Link to comment
Share on other sites

hi

soory my englisch is not so good ...

but i hope you can understand me

okay i have this code

$oFrame = _IEFrameGetObjByName ($oIE1, "up")
$sHTML = _IEDocReadHTML ($oFrame)
$result = StringLeft($shtml, 18)

If $result = "<HTML><HEAD><Meta" Then 
sleep(2*1000)
else
$link=FileReadLine ("bannerlinks.txt", $i )
_IENavigate ($oIE1, $link)
    $i = $i + 1
EndIF
Sleep(2 * 1000)
$oFrame = _IEFrameGetObjByName ($oIE2, "up")
$sHTML = _IEDocReadHTML ($oFrame)
$result = StringLeft($shtml, 18)

If $result = "<HTML><HEAD><Meta" Then 
sleep(2*1000)
else
$link=FileReadLine ("bannerlinks.txt", $i )
_IENavigate ($oIE2, $link)
    $i = $i + 1
EndIF
Sleep(2 * 1000)

is there a way to have this only one time ?

i hope somebody understand me ...

swa

Use For/Next, Do/Until, or While/WEnd to put it in a loop. Read up on those in the help file and try it.

If you get stuck, post what you've got for more help.

^_^

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
Link to comment
Share on other sites

Maybe..

While 1


    $oFrame = _IEFrameGetObjByName($oIE1, "up")
    $sHTML = _IEDocReadHTML($oFrame)
    $result = StringLeft($sHTML, 18)

    If $result = "<HTML><HEAD><Meta" Then
        Sleep(2 * 1000)
    Else
        $link = FileReadLine("bannerlinks.txt", $i)
        _IENavigate($oIE1, $link)
        $i = $i + 1
    EndIf
    Sleep(2 * 1000)
    $oFrame = _IEFrameGetObjByName($oIE2, "up")
    $sHTML = _IEDocReadHTML($oFrame)
    $result = StringLeft($sHTML, 18)

    If $result = "<HTML><HEAD><Meta" Then
        Sleep(2 * 1000)
    Else
        $link = FileReadLine("bannerlinks.txt", $i)
        _IENavigate($oIE2, $link)
        $i = $i + 1
    EndIf
    Sleep(2 * 1000)

WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

I think you could do something like...

Dim $Array[2] = {$oIE1,$oIE2}

For $Index = 0 To Ubound( $Array) -1
    $oFrame = _IEFrameGetObjByName ($Array[$Index], "up")
    $sHTML = _IEDocReadHTML ($oFrame)
    $result = StringLeft($shtml, 18)

    If $result = "<HTML><HEAD><Meta" Then 
        sleep(2*1000)
    else
        $link=FileReadLine ("bannerlinks.txt", $i )
        _IENavigate ($oIE1, $link)
        $i = $i + 1
    EndIF
    Sleep(2 * 1000)
Next

Not sure if my array initialization is correct, but this should do what you want.

Link to comment
Share on other sites

okay but a error

$i=1
Do
Dim $Array[10] = {$oIE1,$oIE2,$oIE3,$oIE4,$oIE5,$oIE6,$oIE7,$oIE8,$oIE9,$oIE10}

For $Index = 0 To Ubound( $Array) -1
    $oFrame = _IEFrameGetObjByName ($Array[$Index], "up")
    $sHTML = _IEDocReadHTML ($oFrame)
    $result = StringLeft($shtml, 18)

    If $result = "<HTML><HEAD><Meta" Then
        sleep(2*1000)
    else
        $link=FileReadLine ("bannerlinks.txt", $i )
        _IENavigate ($Array[$Index], $link)
        $i = $i + 1
    EndIF
    Sleep(2 * 1000)
Next
Until $i = 101

the error is in Line

Dim $Array[10] = {$oIE1,$oIE2,$oIE3,$oIE4,$oIE5,$oIE6,$oIE7,$oIE8,$oIE9,$oIE10}
Dim $Array[10] = ^ Error


Error: Unable to parse line.
Link to comment
Share on other sites

Maybe...

Global $i = 1

For $x = 1 To 2 ; or 1000

    If IsInt($x / 2) Then
        $IE = $oIE2
    Else
        $IE = $oIE1
    EndIf

    $oFrame = _IEFrameGetObjByName($IE, "up")
    $sHTML = _IEDocReadHTML($oFrame)
    $result = StringLeft($sHTML, 18)

    If $result = "<HTML><HEAD><Meta" Then
        Sleep(2 * 1000)
    Else
        $link = FileReadLine("bannerlinks.txt", $i)
        If @error = -1 Then ExitLoop ; when the file is done, this will get you out of the loop
        _IENavigate($IE, $link)
        $i = $i + 1
    EndIf
    
    Sleep(2 * 1000)

Next

.... NOT TESTED

8)

EDIT... Fixed small error

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Global $i = 1

While 1

    For $x = 1 To 10

        $IE = Eval($oIE & $x) 

        $oFrame = _IEFrameGetObjByName($IE, "up")
        $sHTML = _IEDocReadHTML($oFrame)
        $result = StringLeft($sHTML, 18)

        If $result = "<HTML><HEAD><Meta" Then
            Sleep(2 * 1000)
        Else
            $link = FileReadLine("bannerlinks.txt", $i)
            If @error = -1 Then Exit ;Loop ; when the file is done, this will get you out of the loop
            _IENavigate($IE, $link)
            $i = $i + 1
        EndIf

        Sleep(2 * 1000)

    Next

WEnd

8)

NEWHeader1.png

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...