kemo1987 Posted November 18, 2011 Share Posted November 18, 2011 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 Link to comment Share on other sites More sharing options...
czardas Posted November 18, 2011 Share Posted November 18, 2011 Have you tried using _ArrayUnique That should solve your problem. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kemo1987 Posted November 18, 2011 Author Share Posted November 18, 2011 more explain plz as i'm new here and all i did by this forum help Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2011 Share Posted November 18, 2011 _ArrayUnique <- Help File <- More Explain AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted November 18, 2011 Share Posted November 18, 2011 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 kemo1987 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kemo1987 Posted November 18, 2011 Author Share Posted November 18, 2011 thanks all czardas thank you for help it work well Link to comment Share on other sites More sharing options...
czardas Posted November 18, 2011 Share Posted November 18, 2011 You're welcome. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now