GodForsakenSoul Posted June 25, 2009 Share Posted June 25, 2009 since i learned about FileWrite i decided to use it as an idea for an eye. what i need to learn is how to compare one .txt file to another. or more specifically, PARTS of another. suggestions please? Link to comment Share on other sites More sharing options...
OchoNueve Posted June 25, 2009 Share Posted June 25, 2009 since i learned about FileWrite i decided to use it as an idea for an eye.what i need to learn is how to compare one .txt file to another. or more specifically, PARTS of another.suggestions please?There are a couple of functions in the AutoIT Help file that do this. Try:FileReadFileReadLine_FileReadToArray [font="Times New Roman"]Ocho.[/font] Link to comment Share on other sites More sharing options...
FaT3oYCG Posted June 25, 2009 Share Posted June 25, 2009 use _FileReadToArray so you get an array of line to load both files then they will both be stored in your program in the same format, then use StringMid() to select the part of each specific line that you want and use If $a == $b then to compare them. you could also use StringCompare() which would tell you if they are the same or if one has a higher value than the other. Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right. Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted June 25, 2009 Author Share Posted June 25, 2009 -_______-; if course. if there's FileWrite, then there HAS to be FileRead. i feel stupid now. i'm having trouble understanding the example from the helpfile though. (about _FileReadToArray) it would be great if you spent another 5 minutes or so to write me an example you would use to teach a retard with. thank you in advance. Link to comment Share on other sites More sharing options...
FaT3oYCG Posted June 25, 2009 Share Posted June 25, 2009 (edited) Dim $array[1] _FileReadToArray(@ScriptDir & "\file.txt", $array) MsgBox(0, "no of lines", $array[0]) MsgBox(0, "line 1", $array[1]) Edited June 25, 2009 by FaT3oYCG Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right. Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted June 25, 2009 Author Share Posted June 25, 2009 Dim $array[1] _FileReadToArray(@ScriptDir & "\file.txt", $array) MsgBox(0, "no of lines", $array[0]) MsgBox(0, "line 1", $array[1]) and finally, tell me if i got it right, please. i want to be sure i understand this. i want to compare these two files. dim $arrayone[1] dim $arraytwo[1] _FileReadToArray(@ScriptDir\Data&"colordump1.txt", $arrayone[1]) _FileReadToArray(@ScriptDir\Data&"colordump.txt, $arraytwo[1]) if $arrayone[1] == $arraytwo[1] then <insert more code. too lazy to make up more> i need to compare the two files to see if they're IDENTICAL. Link to comment Share on other sites More sharing options...
FaT3oYCG Posted June 25, 2009 Share Posted June 25, 2009 (edited) if you need to see if they are exactly identical then you can use $file1 = FileRead(@ScriptDir & "\file1.txt") $file2 = FileRead(@ScriptDir & "\file2.txt") $same = StringCompare($file1, $file2) If $same Then ;code Edited June 25, 2009 by FaT3oYCG Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right. Link to comment Share on other sites More sharing options...
OchoNueve Posted June 25, 2009 Share Posted June 25, 2009 _FileReadToArray(@ScriptDir\Data&"colordump1.txt", $arrayone[1]) _FileReadToArray(@ScriptDir\Data&"colordump.txt, $arraytwo[1]) Almost right, but I think these two lines should be: _FileReadToArray(@ScriptDir & "\Data" & "\colordump1.txt", $arrayone[1]) _FileReadToArray(@ScriptDir & "\Data" & "\colordump.txt, $arraytwo[1]) If your files are set up the way I think they are being set up. [font="Times New Roman"]Ocho.[/font] 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