Jump to content

Few string checkers


Recommended Posts

Hi all, I need some help with adding few stringinctr , I call it string checker :)

Ok, this is my script now (cuted all other junk that u dont need to see)

$oIE = _IECreate("http://www.link.com)
;
$i = 0
While $i <= 10000
    _IELinkClickByText($oIE, "Linktext")

$body = _IEBodyReadHTML($oIE)
If StringInStr($body, "text 1") Then
_IELinkClickByIndex($oIE, 3)
ContinueLoop
Else
  ContinueLoop
EndIf
Exit

    $i = $i + 1
WEnd

This is only one checker. What I need is to place one more checker somewhere which would search for other word when _IELinkClickByText is working. Tried to place everywhere but it just wont work. Any advices?

Link to comment
Share on other sites

Not sure what you want, but there are several mistakes in your code. See the comments below.

$oIE = _IECreate("http://www.link.com")
;
$i = 0
While $i <= 10000
    _IELinkClickByText($oIE, "Linktext")

    $body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "text 1") Then
        _IELinkClickByIndex($oIE, 3)
        ContinueLoop ; This happens regardless of the conditional If statement
    Else
        ContinueLoop ; This happens regardless of the conditional If statement
    EndIf
    Exit ; This line will never be reached becuase you use ContinueLoop above

    $i = $i + 1 ; This line will never be reached becuase you use ContinueLoop and Exit above
WEnd

Basically what you have written can be simplified as follows (both scripts do exactly the same thing):

$oIE = _IECreate("http://www.link.com")

For $i = 0 To 10000
    _IELinkClickByText($oIE, "Linktext")
    $body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "text 1") Then
        _IELinkClickByIndex($oIE, 3)
    EndIf
Next

First try to understand exactly what your code is doing before you add any new arguments. I hope this helps you.

Happy New Year. :)

Edited by czardas
Link to comment
Share on other sites

Happy New Year to all! Czardas, thanks I will check it tomowow but it seems be working.

Im really newbie so I dont understand much.

Talking about ContinueLoop, day ago I had problem that script was stoping after string check so I just used ContinueLoop... It worked perfectly since my scripts are very simple. Thanks for showing mistakes :)

And I see you didnt answered my question .

I need to add to two

_IELinkClickByText($oIE, "Linktext")
    $body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "text 1") Then
        _IELinkClickByIndex($oIE, 3)

Which would search for text 1 and if its found do something, and other which would search for text 2 and do smth, if not found text 1 and text2 then continue loop.

(Sorry if I somethink didnt saw, my english is very bad)

Link to comment
Share on other sites

If StringInStr($body, "text1") And StringInStr($body, "text2") Then _IELinkClickByIndex($oIE, 3)

This will only execute the _IELinkClick if search 1 AND search 2 are successful. A question for you. Are something and something else two different things? Or the same?

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

That thing I know, I need two different things. If 1 search found then _IELinkClickByIndex($oIE, 3 , If 2search found then for example IENavigate to url...

I tried to place two checkers but it wont works

$body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "text 1") Then
        _IELinkClickByIndex($oIE, 3)
If StringInStr($body, "text 2") Then
        _IELinkClickByIndex($oIE, 1)

This is for example what I mean. It must be possible but I dont know how to do it correctly,

Edit: Maybe something I can make with case? Dont know exactly what it means... :)

Edited by sirfearless
Link to comment
Share on other sites

Oh, I never thought that it will work :

$oIE = _IECreate("http://www.link.com")
$i = 0
Do
For $i = 0 To 1
    _IELinkClickByText($oIE, "link")
    $body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "test 1") Then
        _IELinkClickByIndex($oIE, 3)
    EndIf
Next
For $i = 0 To 1
    _IELinkClickByText($oIE, "same link")
    $body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "text 2") Then
        _IENavigate($oIE, "link")
    EndIf
Next
    $i = $i + 1
Until $i = 10000

I know there is unnecessary things... Its good for me if its working :)

Edited by sirfearless
Link to comment
Share on other sites

Hmm, if only I knew what you were trying to do. I've added some comments to explain why you have created an infinite loop.

$oIE = _IECreate("http://www.link.com")
$i = 0 ; $i now equals 0
Do ; Forever
    For $i = 0 To 1 ; $i now equals 0
        _IELinkClickByText($oIE, "link")
        $body = _IEBodyReadHTML($oIE)
        If StringInStr($body, "test 1") Then
            _IELinkClickByIndex($oIE, 3)
        EndIf
    Next
    ; $i now equals 2
    For $i = 0 To 1 ; $i now equals 0
        _IELinkClickByText($oIE, "same link")
        $body = _IEBodyReadHTML($oIE)
        If StringInStr($body, "text 2") Then
            _IENavigate($oIE, "link")
        EndIf
    Next
    ; $i now equals 2
    $i = $i + 1 ; $i now equals 3
Until $i = 10000 ; ; $i NEVER equals 10000

Every time you enter the For loop, $i is reset to zero, so your code is not making much sense. If you wish to run the main loop 10000 times, then instead of using $i to increase the count, use a different variable name (to avoid corrupting the count). If it is an infinite loop you wish to create then just use a While loop.

Link to comment
Share on other sites

Yep, I want to make infinite loop. Seems that I found out my solutions to make few string checkers I need to use if....Then... ElseIf....then and so on? All I needed is that :) I dont undertand much of these variables and other things ... Firstly I want to learn basic, and get it to work.

Link to comment
Share on other sites

Okay here's how to do it with an infinite While loop.

$oIE = _IECreate("http://www.link.com")

While 1
    For $i = 0 To 1 ; Why are you repeating the following code?
        _IELinkClickByText($oIE, "link")
        $body = _IEBodyReadHTML($oIE)
        If StringInStr($body, "test 1") Then
            _IELinkClickByIndex($oIE, 3)
        EndIf
    Next
    For $i = 0 To 1 ; Why are you repeating the following code?
        _IELinkClickByText($oIE, "same link")
        $body = _IEBodyReadHTML($oIE)
        If StringInStr($body, "text 2") Then
            _IENavigate($oIE, "link")
        EndIf
    Next
WEnd

I'm not sure why you are repeating each set of actions twice by using the For loops. See comments in the code.

Link to comment
Share on other sites

That was my old script. I didnt knew about else if. So it wasnt working.

now my code looks

$oIE = _IECreate("http://www.link.com")
While 1
        _IELinkClickByText($oIE, "link")
        $body = _IEBodyReadHTML($oIE)
        If StringInStr($body, "test 1") Then
            _IELinkClickByIndex($oIE, 3)
         $body = _IEBodyReadHTML($oIE)
        ElseIf StringInStr($body, "text 2") Then
            _IENavigate($oIE, "link")
        EndIf
    Next
WEnd

Also I cant figure out how to click link. One link just wont work so im trying to use

_IEGetObjById ($oIE, "id got from inspect")

_IEAction ($oIE, "click")

It have to work but I think one line is missing.

Edited by sirfearless
Link to comment
Share on other sites

If you look in the help file it tells you what the return value is for the function _IECreate()

Returns an object variable pointing to an InternetExplorer.Application object

So that is what it is. You should look up the following basic terms and try to understand their meanings:

• variable

• conditional statement

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