Jump to content

count the times text exists


Recommended Posts

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

 

Link to comment
Share on other sites

  • Moderators

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

"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 comment
Share on other sites

  • Moderators

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

"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 comment
Share on other sites

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

 

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

Link to comment
Share on other sites

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

 

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