Jump to content
Sign in to follow this  
wisem2540

count the times text exists

Recommended Posts

wisem2540

I am using ZebraNet Bridge to upgrade our fleet of zebra printers.  The script works fine, and upgrades one printer, waits for it to complete and moves to the next.  I would like to start say 3 at a time, and wait for them all to finish, then start 3 more.

Here is the output from Window Info.  Basically. I am using WinGetText to read the window in a loop until it finds "Operation Complete".  What I need to know is, Is there a way to wait for it to show Operation Complete 3 times?

Downloading Printer Firmware to: 10.10.13.19
<a>Clear</a>
Operation Complete
<a>Details...</a>
Downloading Printer Firmware to: 10.10.13.12
<a>Clear</a>
Operation Complete
<a>Details...</a>
Downloading Printer Firmware to: 10.10.13.5
<a>Clear</a>
Operation Complete
<a>Details...</a>
Auto open when a task is added
Clean up

 

Share this post


Link to post
Share on other sites
JLogan3o13

Without seeing all of your code, you could do something like so:

 

Local $x = 0

;Inside WinGetText Loop
    $var = WinGetText(<window>)
    If stringinstr($var, "Operation Complete", Default, 3) Then $x += 1
    If $x = 3 Then
       ;do next action

 

Bleh, forget what I said, I had an idiot moment. If the window is not clearing between runs that if statement will always be true. Adjusted code to look for third occurance.

 

 

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
wisem2540

Jlogan,

thank you...so simple.  I should have thought about that, but if I am looking for 3rd occurrence then I shouldnt have to increase X right?

Edited by wisem2540

Share this post


Link to post
Share on other sites
JLogan3o13

Correct. Sorry for the confusion, was running off to a meeting and trying to finish the post. It should be something like this:

 

While 1
    $sVar = WinGetText("My Window", "")
        If StringInStr($sVar, "Operation Complete", Default, 3) Then
            ;Do Stuff
            ;ExitLoop When stuff Is done
        EndIf
WEnd

 

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
iamtheky

or with replace

_CheckString("Operation Complete ")   ;1st
_CheckString("Operation Complete " & @CRLF & "Operation Complete ")   ;2nd
_CheckString("Operation Complete " & @CRLF & "Operation Complete " & @CRLF & "Operation Complete ")  ;3rd


Func _CheckString($sString)
stringreplace($sString , "Operation Complete" , "Operation Complete")
If @Extended = 3 Then
    msgbox(0, @extended & " match(es)" , "Yay 3 of them!")
Else
    msgbox(0, @extended & " match(es)" , "not yet!")
EndIf
EndFunc

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
jguinch

or with a regex :

$sHTML = "Downloading Printer Firmware to: 10.10.13.19" & @CRLF & _
         "<a>Clear</a>" & @CRLF & _
         "Operation Complete" & @CRLF & _
         "<a>Details...</a>" & @CRLF & _
         "Downloading Printer Firmware to: 10.10.13.12" & @CRLF & _
         "<a>Clear</a>" & @CRLF & _
         "Operation Complete" & @CRLF & _
         "<a>Details...</a>" & @CRLF & _
         "Downloading Printer Firmware to: 10.10.13.5" & @CRLF & _
         "<a>Clear</a>" & @CRLF & _
         "Operation Complete" & @CRLF & _
         "<a>Details...</a>" & @CRLF & _
         "Auto open when a task is added" & @CRLF & _
         "Clean up"
         
MsgBox(0, "", _StringCount($sHTML, "Operation complete" ) )



Func _StringCount($sString, $sSearch, $iCaseSense = 0, $iRegExMode = 0 )
    Local $sCaseSense = "(?i)", $sRegExStart = "\Q", $sRegExEnd = "\E"
    If $iCaseSense Then $sCaseSense = ""
    If $iRegExMode Then
        $sRegExStart = ""
        $sRegExEnd = ""
    EndIf
    
    Return UBound ( StringRegExp($sString, $sCaseSense & $sRegExStart & $sSearch & $sRegExEnd, 3) )
EndFunc

 

  • Like 1

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  

×