Jump to content

avoid write duplicated lines to text


kemo1987
 Share

Recommended Posts

this func adding write new lines to result.txt every 10 second

i want first check if line duplicated then dont write it to text

sometimes this array also have dupilcated lines so if we check text evertime b4 write each line it will be ok

Example of result text

14:09:55.3 Call (l:'sip:115@61.8.157.58' r:'sip:00201120675645@61.8.157.58') - Placing call.

14:09:55.3 Call (l:'sip:115@61.8.157.58' r:'sip:00201120675645@61.8.157.58') - Placing call.

14:10:01.7 Call (l:'sip:115@61.8.157.58' r:'sip:000201120675645@61.8.157.58') - Placing call.

14:09:55.3 Call (l:'sip:115@61.8.157.58' r:'sip:00201120675645@61.8.157.58') - Placing call.

anyway i need to dont write duplicate line whatever it contain.

Func _asaving()
;WinWaitActive("eyeBeam","")
WinActivate("[CLASS:SUAWINCLIENTCLASS]", "")
ControlSend("[CLASS:SUAWINCLIENTCLASS]", "", "","{F9}")
$var = ControlGetText("[CLASS:DIAGNOSTICDIAG_CLASS]", "", "Edit1")
$lines = StringSplit($var, @CRLF, 1)
$words = " Call "
For $i = 1 To Ubound( $lines ) - 1
  If StringInStr($lines[$i], $words)   Then
    ClipPut($lines[$i] & @CRLF)
$file = FileOpen("result.txt", 1)
; Check if file opened for writing OK
If $file = -1 Then
  MsgBox(0, "Error", "Unable to open file.")
  Exit
EndIf
FileWriteLine($file, $lines[$i] & @CRLF)
FileClose($file)
  EndIf
Next
;WinWaitActive("eyeBeam","")
WinActivate("[CLASS:SUAWINCLIENTCLASS]", "")
ControlSend("[CLASS:SUAWINCLIENTCLASS]", "", "","{F9}")
EndFunc

Thanks in advance :D

Link to comment
Share on other sites

I haven't tested this, but it should work.

#include <Array.au3>

Func _asaving()
;WinWaitActive("eyeBeam","")
WinActivate("[CLASS:SUAWINCLIENTCLASS]", "")
ControlSend("[CLASS:SUAWINCLIENTCLASS]", "", "","{F9}")
$var = ControlGetText("[CLASS:DIAGNOSTICDIAG_CLASS]", "", "Edit1")
$lines = StringSplit($var, @CRLF, 1)
$lines = _ArrayUnique($lines, 1, 1) ;====> Remove duplicates from the 1-base index array

$words = " Call "
For $i = 1 To Ubound( $lines ) - 1
      If StringInStr($lines[$i], $words)   Then
        ClipPut($lines[$i] & @CRLF)
        $file = FileOpen("result.txt", 1)
        ; Check if file opened for writing OK
        If $file = -1 Then
          MsgBox(0, "Error", "Unable to open file.")
          Exit
        EndIf
        FileWriteLine($file, $lines[$i] & @CRLF)
        FileClose($file)
      EndIf
Next
;WinWaitActive("eyeBeam","")
WinActivate("[CLASS:SUAWINCLIENTCLASS]", "")
ControlSend("[CLASS:SUAWINCLIENTCLASS]", "", "","{F9}")
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...