boji Posted March 19, 2008 Share Posted March 19, 2008 Again, I apoligise in advance for my noobness, but I'm having trouble with the syntax on the condition: IF Clipget 1 = Clipget 2 Then... I do not know how to keep Clip1 buffered so as to have it be compared to Clip2 Would this require saving Clip1 first? I appricate any help you might be able to give me. Also if I missed a section on this forum that deals with this kind of problem, feel free to chastise me. Link to comment Share on other sites More sharing options...
boji Posted March 20, 2008 Author Share Posted March 20, 2008 (edited) $sFile1 = "TM Difference File2.txt" $sFile2 = "TM Difference File1.txt" If $sFile1 = $sFile2 Then MsgBox(64,"","Matched !") Else MsgBox(64,"","Didn't match..") EndIf Does not work either. I imagine that the string $sFile1 = only text, not the actual files with data in it. Is there any way around this? Thank for your advice in advance. Edited March 20, 2008 by boji Link to comment Share on other sites More sharing options...
Kerros Posted March 20, 2008 Share Posted March 20, 2008 How about _readFiletoArray, and then comparing the arrays? a longer way would to to do something along this line $file = FileOpen("C:\file.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open text file #1.") Exit EndIf $file1 = FileOpen("C:\file1.txt", 0) If $file1 = -1 Then MsgBox(0, "Error", "Unable to open text file #2.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $text = $line $line1 = filereadline($file1) If @error = -1 Then ExitLoop $text1 = $line1 if $line = line1 then MsgBox(64,"","Matched !") Else MsgBox(64,"","Didn't match..") EndIf WEnd FileClose($file) FileClose($file1) Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 20, 2008 Moderators Share Posted March 20, 2008 How about _readFiletoArray, and then comparing the arrays? a longer way would to to do something along this line $file = FileOpen("C:\file.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open text file #1.") Exit EndIf $file1 = FileOpen("C:\file1.txt", 0) If $file1 = -1 Then MsgBox(0, "Error", "Unable to open text file #2.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $text = $line $line1 = filereadline($file1) If @error = -1 Then ExitLoop $text1 = $line1 if $line = line1 then MsgBox(64,"","Matched !") Else MsgBox(64,"","Didn't match..") EndIf WEnd FileClose($file) FileClose($file1) Don't really see how this helps with him comparing what is in the clip board... but just so you know, this may be a bit faster:If FileGetSize($hFile1) = FileGetSize($hFile2) Then MsgBox(64, "Info", "Files the same") Or If StringCompare(FileRead($hFile1), FileRead($hFile2)) = 0 Then MsgBox(64, "Info", "Files the same") @OP: What type of data is on the clip board? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 20, 2008 Share Posted March 20, 2008 $sFile1 = "TM Difference File2.txt" $sFile2 = "TM Difference File1.txt" If $sFile1 = $sFile2 Then MsgBox(64,"","Matched !") Else MsgBox(64,"","Didn't match..") EndIf Does not work either. I imagine that the string $sFile1 = only text, not the actual files with data in it. Is there any way around this? Thank for your advice in advance. You want to compare the actual files? You could just Run() the command line shell FC.exe or Comp.exe commands and parse the output. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
boji Posted March 24, 2008 Author Share Posted March 24, 2008 Don't really see how this helps with him comparing what is in the clip board... but just so you know, this may be a bit faster:If FileGetSize($hFile1) = FileGetSize($hFile2) Then MsgBox(64, "Info", "Files the same") Or If StringCompare(FileRead($hFile1), FileRead($hFile2)) = 0 Then MsgBox(64, "Info", "Files the same") @OP: What type of data is on the clip board?The data on the clipboard is 1 line of simple text. The data to compare is a ControlGetText, also a simple line of text, once modified with StringStrip and Trim. You guys rock, thanks for your ideas on this. I'll try all versions. As for using the external program, would u mind showing me an example of how to pull the output back into autoit for analysis? I'll troll for this answer in the meantime. Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 24, 2008 Share Posted March 24, 2008 The data on the clipboard is 1 line of simple text. The data to compare is a ControlGetText, also a simple line of text, once modified with StringStrip and Trim. You guys rock, thanks for your ideas on this. I'll try all versions. As for using the external program, would u mind showing me an example of how to pull the output back into autoit for analysis? I'll troll for this answer in the meantime. Either run the command line with redirection to a file:RunWait(@ComSpec & '/c FC.exe "C:\Temp\File1.txt" "C:\Temp\File2.txt" > "C:\Temp\Results.txt"', @TempDir, @SW_SHOW) Run('notepad.exe "C:\Temp\Results.txt"') ...or learn to use the StdOutRead() functionality. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
boji Posted March 24, 2008 Author Share Posted March 24, 2008 Oh man If StringCompare(FileRead($hFile1), FileRead($hFile2)) = 0 Then MsgBox(64, "Info", "Files the same") Works perfectly! I'm getting the output i need to continue the program. Thank you so much! There ought to be a tip jar round' here somewhere. U guys deserve it. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 24, 2008 Moderators Share Posted March 24, 2008 Oh manIf StringCompare(FileRead($hFile1), FileRead($hFile2)) = 0 Then MsgBox(64, "Info", "Files the same")Works perfectly! I'm getting the output i need to continue the program. Thank you so much! There ought to be a tip jar round' here somewhere. U guys deserve it.There is: http://www.autoitscript.com/donate.php Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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