Sign in to follow this  
Followers 0
EmptySpace

Few string checkers

14 posts in this topic

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?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Now the code is looking a bit more sensible. I don't know if it does what you want it to do, but at least I understand it now. :)

Share this post


Link to post
Share on other sites

Code was doing what I wanted from the begining :)

But it was hard to add something new into it. Now its lot easer. Thanks for help.

Also can you explain what means all these $oIE.

It just says that line will work into

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

Share this post


Link to post
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

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