Jump to content
Sign in to follow this  
swa

noob need help by loop

Recommended Posts

swa

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
swa

my problem is the $oie1 and $oie2

how make it in loops ??

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
swa

year but can I make it so that i say the loop run two times and on the first run its $oIE1 and the 2th time $oIE2 ?

Share this post


Link to post
Share on other sites
DavidKarner

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.

Share this post


Link to post
Share on other sites
swa

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.

Share this post


Link to post
Share on other sites
oMBRa

replace

{$oIE1,$oIE2,$oIE3,$oIE4,$oIE5,$oIE6,$oIE7,$oIE8,$oIE9,$oIE10}

with

[$oIE1,$oIE2,$oIE3,$oIE4,$oIE5,$oIE6,$oIE7,$oIE8,$oIE9,$oIE10]

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
swa

Valuater the problem is that are 10 websites

forgotten to say soory

i make only 2 to make it understand

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
swa

soory Valuater iam a noob

$IE = Eval($oIE & $x)
$Ie = Eval (^Error

Error: Variable used without being declared

soory a 2th time

swa

Share this post


Link to post
Share on other sites
Valuater

Remember this is done without testing... I think it's

$IE = Eval("oIE" & $x)

Sorry!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
swa

i have to say soory...

you want to help me and that it isnĀ“t tested its okay its my job :-D

Share this post


Link to post
Share on other sites
swa

but why it is so slowly ?

can I make it faster and when yes how ?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.