Jump to content

Problem with runing statemens


Recommended Posts

I can solve it in other way but i want to look it clearly and run smooth.

Func clicklink()
Sleep(4000)
_IELinkClickByText($oIE,$text)
If @error = 7 Then ;if no link found
_IELinkClickByText($oIE,$text2)
If @error = 7  Then ; link text2 wasnt found then
_IELinkClickByText($oIE,$text3)
If all errors then ;if no links found then
_ieaction($oIE,"refresh")
Endif
Endfunc

So how i can write this? Maybe its possible with case or smthg?

Link to post
Share on other sites
  • Moderators

If I am understanding you correctly, maybe a For loop and an error level check would make it easier. Something like this (untested)?

Func clicklink()
Sleep(4000)

Local $ErrLevel = 0
Local $aText[3]
   $aText[0] = ""
   $aText[1] = ""
   $aText[2] = ""

For $link in $aText
_IELinkClickByText($oIE,$link)
  If @error = 7 Then ;if no link found
   $ErrLevel += 1
  EndIf
Next

If $ErrLevel = 3 Then  ;if no links found then
_ieaction($oIE,"refresh")
Endif

Endfunc

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites
  • Moderators

Depending on what you want to do, you need to add an Else into your If Statement:

Func clicklink()
Sleep(4000)
Local $ErrLevel = 0
Local $aText[3]
   $aText[0] = ""
   $aText[1] = ""
   $aText[2] = ""
For $link in $aText
_IELinkClickByText($oIE,$link)
  If @error = 7 Then ;if no link found
   $ErrLevel += 1
   Else
    ;click $link
  EndIf
Next
If $ErrLevel = 3 Then  ;if no links found then
_ieaction($oIE,"refresh")
Endif
Endfunc

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites
  • Moderators

You should be able to use ExitLoop in your Else statement. That way, whichever link it finds it will then exit the For loop.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Yeah, now it works fine. Thanks again for help

Func clicklink()
Sleep(4000)

Local $ErrLevel = 0
Local $aText[3]
$aText[0] = ""
$aText[1] = ""
$aText[2] = ""

For $link in $aText
_IELinkClickByText($oIE,$link)
If @error = 7 Then ;if no link found
$ErrLevel += 1
else
exitloop
EndIf
Next

If $ErrLevel = 3 Then ;if no links found then
_ieaction($oIE,"refresh")
Endif

Endfunc
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...