Nemcija Posted October 27, 2006 Share Posted October 27, 2006 Huhu, I've got a big problem with FileRead() For example i have got a File: (calculated by an other program) [...] 07 7C 20 00 - 7D 60 A1 B0 - 12 41 D1 0D - 30 FF [...] Now i read it out (FileRead) and write it down again into an other file.. (exactly the same data) This will be the output: [...] 07 7C 20 00 - 7D 60 A1 B0 - 12 41 D1 0D - 0A 30 FF [...] Am I too stupid, or is it a bug? I know 0D = @CR and 0D0A = @CRLF but i can't fix it by replacing all 0D0A's by 0D because if there is already a 0D0A it won't be changed to 0D0A0A ^^ Maybe this is something for the support forum, but maybe it is a bug. Thanks for reading. Nemcija. [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 27, 2006 Moderators Share Posted October 27, 2006 Did you try: $string = StringReplace(FileRead('whereever.txt'), @CRLF, @CR)? 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...
Valik Posted October 27, 2006 Share Posted October 27, 2006 This is most obviously not a valid bug report. Moved to support. Link to comment Share on other sites More sharing options...
Nemcija Posted October 27, 2006 Author Share Posted October 27, 2006 @SmOke_N: This wouldn't work FileRead converts: [0D0A -> 0D0A] || CRLF -> CRLF (no change) [0A -> 0A] || LF -> LF (no change) but [0D -> 0D0A] || CR -> CRLF (big problem) If I would try now to replace CRLF by CR I would replace the real CRLF, too. Do you now understand my problem? [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
Nemcija Posted October 27, 2006 Author Share Posted October 27, 2006 nobody an idea? [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
Developers Jos Posted October 27, 2006 Developers Share Posted October 27, 2006 nobody an idea? You will have post an script plus input file that shows the exact problem if you want us to help you. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nemcija Posted October 27, 2006 Author Share Posted October 27, 2006 (edited) Ok ok .. 3rd time i write it now Inputfiledata (pe "input.file") in hexeditor: [...] 07 7C 20 00 - 7D 60 A1 B0 - 12 41 D1 0D - 30 FF [...] Now i read it out with Autoit (real code of the script more than 1000 lines long) But i want to write an example to show it to you: $filedata = fileread("input.file") ; [...] ; Work with a copy of $filedata ; Here i get an error at 0D when 0A has been added ; ( not fixable in this codepart! ) ; [...] filewrite("output.file", $filedata) Now i open "output.file" in a hexeditor: [...] 07 7C 20 00 - 7D 60 A1 B0 - 12 41 D1 0D - 0A 30 FF [...] FileRead converts: [0D0A -> 0D0A]|| CRLF -> CRLF (no change) [0A -> 0A] || LF -> LF (no change) but [0D -> 0D0A] || CR -> CRLF (big problem) If I try to replace CRLF by CR I would replace the real CRLF, too. Do you now understand my problem? Edited October 27, 2006 by Nemcija [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2006 Developers Share Posted October 28, 2006 Ok ok .. 3rd time i write it now I have read what you written.... and do not see an attached file .... Maybe it would be nice if you supply the file you test with in stead of expecting it from us to create it . anyways.. made this script which I think does what you want and do not see the problem... what hex Editor do you use ?: #include<String.au3> FileDelete("Test.hex") FileDelete("Test2.hex") $String = _HexToString("077C20007D60A1B01241D10D30FF") Filewrite("Test.hex",$String) $test = FileRead("Test.hex") Msgbox(0,"debug",_StringToHex($test)) Filewrite("Test2.hex",$String) $test = FileRead("Test2.hex") Msgbox(0,"debug",_StringToHex($test)) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nemcija Posted October 28, 2006 Author Share Posted October 28, 2006 (edited) I m using Hex-Editor MX (v6) from Nextsoft. in my script i use it like this:$filehandle = FileOpen($file,0) $filedata = FileRead($filehandle) for $dataset = $start to $end $input = StringMid($filedata,StringInStr($filedata, "-Data-",0,1)+8+($dataset*11),11) ; StringInStr($filedata, "-Data-",0,1)+8 sets it to beginning. if you ask why "+8" -Data-=6 +CRLF=2 =8 ;$dataset is the entrynumber $output = _StringToHex($input) FileWriteLine("Debug.txt",$input & " >>> " & $output) ; Debug ;[ ... ] Next here an example of my debugdata:[...] (everything correctly) }`¡°a± >>> 070510007D60A1B01241B1 {P }`¡°aÑ >>> 077B50007D60A1B01241D1 | }`¡°añ >>> 077C20007D60A1B01241D1 | }`¡°b >>> 077C20007D60A1B012420D |0 }`¡°b >>> 0A077C30007D60A1B01242 1~ð }`¡°b >>> 31077ED0007D60A1B01242 Ep }`¡°a >>> 014550007D60A1B0124110 P }`¡°a >>> 019550007D60A1B0124120 [...]You maybe see that there should be exactly 8 numbers before 7D6. Edit: I have found out something new. before i read it out i write it down (seems to be logical ) FileWrite already adds 0A if there is only a 0D ok someone know how to fix this ? ^^ Edited October 28, 2006 by Nemcija [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2006 Developers Share Posted October 28, 2006 FileWrite already adds 0A if there is only a 0Dok someone know how to fix this ? ^^It does not as you can see in my example.... agree ?I am willing to have a look at the issue when you provide everything that will allow me to replicate your problem.. the code you posted does not and you haven't attached the input file you use.. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GaryFrost Posted October 28, 2006 Share Posted October 28, 2006 Why are you using a Hex Editor and debug data? You attempting read and exe and write it back out? SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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