Sign in to follow this  
Followers 0
kemo1987

search in $var and return with line include search value?

6 posts in this topic

00:18:03.4 Call (l:'sip:5988@193.221.96.1' r:'sip:00110020100775352@193.221.96.1') - Call failed. Error code: 486 "Busy Here"

00:44:31.1 Proxy slot #0 () - Failed to register! error-code: 408, msg: 'Request Timeout'. Retry in 40 second(s). AOR: '<sip:100@177.16.246.156>', proxy: '177.16.246.156', firewall-proxy: 'F'.

00:45:39.0 Proxy slot #0 () - Registration failed AOR: '<sip:100@177.16.246.156>', proxy: '177.16.246.156', firewall-proxy: 'F'.

00:47:41.0 RequestPlaceCall to 'sip:001900380935188967@177.17.11.203' on an inactive proxy!

================

$var = ControlGetText("[CLASS:DIAGNOSTICDIAG_CLASS]", "", "Edit1")

$var > contain text like above

i want search for highlight text if exist in any line > write that line to result.txt

and i want make variable like $words so i can change search value.

Thanks in advance.

Share this post


Link to post
Share on other sites



Hello kemo,

just do a SplitString with @CRLF as the delimiter, then you have an array you can loop through. Then you can do a stringInStr, to find the coorect lines.

1 person likes this

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

How about this handy lil function:

StringInStr($var, $words)

If $var contains more than one line then you could break up the lines into an array passing through a loop to check each line:

$lines = StringSplit($var, @CRLF, 1)

For $i = 1 To Ubound( $lines ) - 1
   If StringInStr($lines[$i], $words) Then
      ;Do Something
   EndIf
Next

Edit: Yeah, what Hannes08 said, lol

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

i will try this thank u

Share this post


Link to post
Share on other sites

something wrong , i need to send each line contain that $words to notepad??

$var = ControlGetText("[CLASS:DIAGNOSTICDIAG_CLASS]", "", "Edit1")
$lines = StringSplit($var, @CRLF, 1)
$words = "Error code"
For $i = 1 To Ubound( $lines ) - 1
If StringInStr($lines[$i], $words)   Then
  ;Do Something
  WinWaitActive("[CLASS:Notepad]")
  ControlSend("[CLASS:Notepad]", "", "", "{ENTER} "& $lines &" {ENTER}")
  Sleep(5000)
   EndIf
Next

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You left the subscript ([$i]) off of the $lines reference in your ControlSend() statement.

Edit: PS - You'd run a lot faster if you just wrote your output direct to a text file via FileWriteLine(). But if having notepad.exe up and running is a requirement, you could at least use the clipboard to transfer your data as it is light-years faster than having ControlSend() process the whole string.

$var = "Line1 Error code" & @CRLF & "Line2" & @CRLF & "Line3 Error code" & @CRLF & "Line4" & @CRLF & "Line5 Error code" & @CRLF
$lines = StringSplit($var, @CRLF, 1)
$words = "Error code"
Run("Notepad.exe")
WinWaitActive("[CLASS:Notepad]")

; really slow
Sleep(1000)
For $i = 1 To Ubound( $lines ) - 1
  If StringInStr($lines[$i], $words)   Then
    ControlSend("[CLASS:Notepad]", "", "", $lines[$i] & "{ENTER}")
  EndIf
Next

ControlSend("[CLASS:Notepad]", "", "", "{ENTER}")

; slow
Sleep(1000)
For $i = 1 To Ubound( $lines ) - 1
  If StringInStr($lines[$i], $words)   Then
    ClipPut($lines[$i] & @CRLF)
    ControlSend("[CLASS:Notepad]", "", "", "^v")
  EndIf
Next
Edited by Spiff59
1 person likes this

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