jorgeng Posted March 17, 2009 Posted March 17, 2009 Hello. I have an autoit-script which reads a file every minute and does a compare with another file. If the files differ we write the first file with filewrite. It works but there are now strings with timestamp some times a day so the outputfile looks messy. how do i do so every line written has an eof mark, meaning i want the new message on a new line Now it looks: 14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ I want: 14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ Part of my code: FileWrite($file_Omx_Wampa, $var_original & @CRLF)
PsaltyDS Posted March 17, 2009 Posted March 17, 2009 Hello.I have an autoit-script which reads a file every minute and does a compare with another file.If the files differ we write the first file with filewrite.It works but there are now strings with timestamp some times a day so the outputfile looks messy.how do i do so every line written has an eof mark, meaning i want the new message on a new lineNow it looks:14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ I want:14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ Part of my code:FileWrite($file_Omx_Wampa, $var_original & @CRLF)FileWriteLine(), or if you want a consistent Date/Time stamp added to each line try _FileWriteLog().See help file. 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
jorgeng Posted March 17, 2009 Author Posted March 17, 2009 (edited) FileWriteLine(), or if you want a consistent Date/Time stamp added to each line try _FileWriteLog().See help file. Sorry, filewriteline doesn't work, still same result, any other ideas?14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 16:26 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ Edited March 17, 2009 by jorgeng
Mat Posted March 17, 2009 Posted March 17, 2009 (edited) _FileWriteToLine?? you could use _FileCountLines($sFilePath) + 1 as the line to write to too. MDiesel edit: Don't use the macro @CRLF on this one - as it could read this as a line Edited March 17, 2009 by mdiesel AutoIt Project Listing
Prab Posted March 17, 2009 Posted March 17, 2009 Try adding the macro @CRLF to the end of the string. FolderLog GuiSpeech Assist
Mat Posted March 17, 2009 Posted March 17, 2009 Try adding the macro @CRLF to the end of the string.Am i missing the point? I thought the idea was to make a log that could be edited by scripts run at different times. using @CRLF does NOT solve this problem - It is made for writing files, rather than editing them..am I being stupid again?MDiesel AutoIt Project Listing
Bowmore Posted March 17, 2009 Posted March 17, 2009 (edited) I seems as though we are not understanding what you are wanting to achieve. Could you try and describe your requirements in a different way to make it clearer. In the mean time does any of this help? $Data = "14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$" $Data = stringReplace($Data,'$ ', "$" & @CRLF) fileWrite(Test.text,$Data)oÝ÷ Ù«¢+ØÀÌØí¥± ½¹Ñ¹ÑÌô¥±I ÅÕ½Ðí¥±¹µÅÕ½Ðì¤(ÀÌØí½ÉµÑÑ¥± ½¹Ñ¹ÑÌôÍÑÉ¥¹IÁ± ÀÌØí¥± ½¹Ñ¹Ñ̰ÌäìÀÌØìÌäì°ÅÕ½ÐìÀÌØìÅÕ½ÐìµÀì I1¤)¥±]É¥Ñ ÅÕ½Ðí9Ý¥±¹µÅÕ½Ðì°ÀÌØí½ÉµÑÑ¥± ½¹Ñ¹ÑÌ Edited March 17, 2009 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
jorgeng Posted March 18, 2009 Author Posted March 18, 2009 (edited) Thanks for help Sorry if I am not clear for what i want. The text you see above i can log in to my webplace and look at - a simple htm file. I only wants the formatting to be correct since when a new message comes as first position in file i want it on a a new line. Today it's messy and all text appends at last where previous message stopped to write to file Now it looks: 14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ I want: 14:27 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.2500$ 14:28 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ 14:40 ANALYS "sl) Omx Nexu Sellstop - Kl.11 - Rosa - Krypterat OMXS309C" kurs 662.7500$ I will try _FileCountLines($sFilePath) + 1 as diesel suggested, come back if it works Thanks Edited March 18, 2009 by jorgeng
jorgeng Posted March 18, 2009 Author Posted March 18, 2009 Sorry, can't still get it to work, got error 2 from some file: $CountLines = _FileCountLines($file_Omx_Wampa) MsgBox(4096, "$CountLines", $CountLines) $CountLines = $CountLines + 1 MsgBox(4096, "$file_Omx_Wampa", $file_Omx_Wampa) MsgBox(4096, "$CountLines", $CountLines) MsgBox(4096, "$var_original", $var_original) _FileWriteToLine($file_Omx_Wampa, $CountLines, $var_original,0) MsgBox(4096, "@Error", @Error) FileClose($file_Omx_Wampa)
PsaltyDS Posted March 18, 2009 Posted March 18, 2009 If it's an .htm document, then put an html line break "<br>" in it: FileWriteLine($sFileName, $sData & "<br>") 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
jorgeng Posted March 18, 2009 Author Posted March 18, 2009 If it's an .htm document, then put an html line break "<br>" in it: FileWriteLine($sFileName, $sData & "<br>") Thanks, I try it.
jorgeng Posted March 18, 2009 Author Posted March 18, 2009 Yes, it worked, se log. At 17.19 the lines look correct. Great. Thanks. 09:45 ORDER "sl) Omx Wampa - Stega till Sekvens 9A Kl.09.45 - Okrypterat OMXS309C" kurs 672.0000$ 10:00 ORDER "sl) Omx Wampa Sellstop - Kl.10 - Röd - Okrypterat OMXS309C" kurs 670.2500$10:00 ORDER "sl) Omx Wampa Sellstop - Kl.10 - Röd - Okrypterat OMXS309C" kurs 670.2500$ 12:54 ORDER "sl) Omx Wampa Sellstop - Kl.11 - Rosa - Okrypterat OMXS309C" kurs 663.5000$ 17:18 ORDER "sl) Omx Wampa - Nollställ Depå kl.17.18 - Krypterat OMXS309C" kurs 660.5000$ 17:19 ORDER "sl) Omx Wampa - Nollställ Depå kl.17.18 - Krypterat OMXS309C" kurs 660.0000$ 17:19 ORDER "sl) Omx Wampa - Nollställ Depå kl.17.18 - Krypterat OMXS309C" kurs 659.5000$ 17:20 ORDER "sl) Omx Wampa - Kurs Ovanför Kl.10 Stapel High - Eller Kl.17.20 OMXS309C" kurs 657.2500$ 17:20 ORDER "sl) Omx Wampa - Kurs Ovanför Kl.11 Stapel High - Eller Kl.17.20 OMXS309C" kurs 657.2500$
Mat Posted March 18, 2009 Posted March 18, 2009 (edited) Sorry, can't still get it to work, got error 2 from some file: $CountLines = _FileCountLines($file_Omx_Wampa) MsgBox(4096, "$CountLines", $CountLines) $CountLines = $CountLines + 1 MsgBox(4096, "$file_Omx_Wampa", $file_Omx_Wampa) MsgBox(4096, "$CountLines", $CountLines) MsgBox(4096, "$var_original", $var_original) _FileWriteToLine($file_Omx_Wampa, $CountLines, $var_original,0) MsgBox(4096, "@Error", @Error) FileClose($file_Omx_Wampa)You need to include file.au3This method should work in htm files too, the error you were getting before looks like it was becouse it didn't recognise @CRLF or something...If the other method works fine then don't bother. If it ain't broken, don't try to fix it (I have made this mistakes many times and ended up worse off than I started!)Glad It's working MDiesel Edited March 18, 2009 by mdiesel AutoIt Project Listing
PsaltyDS Posted March 18, 2009 Posted March 18, 2009 (edited) You need to include file.au3This method should work in htm files too, the error you were getting before looks like it was becouse it didn't recognise @CRLF or something...If the other method works fine then don't bother. If it ain't broken, don't try to fix it (I have made this mistakes many times and ended up worse off than I started!)Glad It's working MDieselHe's viewing the .htm document in a browser, so no amount of @CRLF is going to help until he gets an HTML line break ( "<br>" ) in there. Edited March 18, 2009 by PsaltyDS 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
Mat Posted March 18, 2009 Posted March 18, 2009 He's viewing the .htm document in a browser, so no amount of @CRLF is going to help until he gets an HTML line break ( "<br>" ) in there. This method should work in htm files too, the error you were getting before looks like it was becouse it didn't recognise @CRLF or something...basically what I was saying said properly with an explanantion given... AutoIt Project Listing
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