Search the Community
Showing results for tags '_filewritetoline'.
-
#include <File.au3> #include <FileConstants.au3> Local $sTestfile = "_FileWriteToLine.txt" Local $hTestfile = FileOpen($sTestfile, $FO_APPEND) FileWriteLine($hTestfile, "Line 1") FileWriteLine($hTestfile, "Line 2") FileWriteLine($hTestfile, "Line 3") FileClose($hTestfile) _FileWriteToLine("_FileWriteToLine.txt", 2, "Overwritten", True) The above example code first creates a text file that has four lines after FileClose: Line 1 Line 2 Line 3 And an empty line. After _FileWriteToLine only three lines are left: Line 1 Overwritten Line 3 The empty line has been removed by the function _FileWriteToLine!
-
format of numbers while using _filewritetoline
rkr posted a topic in AutoIt General Help and Support
I have a text file which has over 1000 lines, and I wish to replace one particular - I was able to do the replacement - but I have a issue - I want the numbers to be of specific format Eg; my command was as follows, my command >>>>> _filewritetoline($inp_file,$inp_replacement,"WAVE1.00STOK"&$hdet&" "&$tasso&" "&"270.0 D 5.0 72MS 1",true) my output >>>>>> WAVE1.00STOK10.06 9.800 270.0 D 5.0 72MS 1 how do I make sure that the $hdet=10.06 is printed as 10.060(3 digits after decimel) and same with $tasso and so on.. also, how to maintain the required gap between the variables - is it by manually putting spaces ? thanks guys- 5 replies
-
- _filewritetoline
- format
-
(and 1 more)
Tagged with:
-
Hello All, I am having some issues with the below script. I want to take a value from an input box and write it to a text file (stored in the same location named Config.txt). Results: script runs however the text file does not get populated with the result from the input. Any help would be greatly appreciated. #include <File.au3> Global $sIniFile = @ScriptDir & "\" & "Config.txt" MsgBox(1,"",$sIniFile) ;Test to see if $sIniFile is working - Comes back as expected Global $script1 = InputBox("Window Info", "Enter the name of your program identified using Auto Window Info") _FileWriteToLine($sIniFile, 1, $script1, 1)
-
FOr a while now i've been running a script that uses a flat text file to keep track of users to perform actions on. I have some logic in the block that adds new users with some comma delimited fields with FileWriteLine and then updates that line with _FileWriteToLine this has been running fine for years but suddenly i'm having problems with the script crashing because when the very last line of the file is losing it's CRLF so the next appended line concatenates with the last line and the parser fails to parse the last line. this has been driving me nuts for a while so i finally took apart all my code and have discovered that for some reason _FileWriteToLine deletes CRLF off the bottom of the file after use. i don't know why this started suddenly, i even copied an old file.au3 library and it still does it (maybe a change to shell32.dll? ) I was able to replicate the bug by making a new file with each line having CRLF at the end then with the following code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** _FileWriteToLine($FilePath,12,"Test rewrite",1)After running the code and refreshing the file i can see that the last blank line disappears (no final CRLF) Is there a way to prevent this behavior? (without a huge logic rewrite to use a DB or another write method) EDIT: actually it seems that replacing the old au3 is working, or at least working some of the time. not sure if it's a *sometimes* bug with the older library.
-
Hello, I just discovered bad thing. If I used _FileWriteToLine function in AutoIt3 beta since 3.3.9.20 and newer, after launching the file it's partially damaged itself. Older versions work correctly and there is no file damaging. Look at the example and test on different versions - older and newer. (Added): I think the problem is in IncludeFile.au3 v.3.3.9.20, line 677: Local $aArray = StringRegExp(@CRLF & $sFileRead & @CRLF, "(*BSR_ANYCRLF)([^\R]*)(?:\R)(?:\R$)?", 3) v.3.3.9.19, line 683: Local $aArray = StringRegExp(@CRLF & $sFileRead & @CRLF, "([^\r\n]*)(?:\r\n|\n|\r)(?:[\r\n]$)?", 3) Maybe the pipe "|" I used is the reason? #AutoIt3Wrapper_Res_Field=Release date|18.10.2013 partypooper, MrCreatoR? P.S. Excuse me for strange characters in line number 5. It's an online artifact, there is no such characters in my code. #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Comment=http://monter.FM #AutoIt3Wrapper_Res_Description=Example file showing beta bug since AutoIt3.3.9.20. #AutoIt3Wrapper_Res_Field=Release date|18.10.2013 #AutoIt3Wrapper_Res_LegalCopyright=monter.FM #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Date.au3> #include <File.au3> Global $msg, $flg, $sec $title = 'AutoIt3 - version ' & @AutoItVersion FileChangeDir(@ScriptDir) If StringReplace(@AutoItVersion, '.', '') > 33919 Then VerBug() Else VerOK() EndIf FileInfo() MsgBox($flg, $title, $msg, $sec) If $flg = 48 Then Run('notepad.exe ' & @ScriptName) Func VerBug() $msg = 'This version has just damaged this file.' & @CRLF & 'Fortunately I made the *.bak copy :)' & @CRLF & 'Look at this damaged script now.' $flg = 48 $sec = 6 FileCopy(@ScriptName, @ScriptName & '.bak') EndFunc ;==>VerBug Func VerOK() $msg = "This version works fine and shouldn't damage this file." $flg = 64 $sec = 3 EndFunc ;==>VerOK Func FileInfo() Opt('TrayIconDebug', 1) $strRes = '#AutoIt3Wrapper_' For $ln = 1 To 10 $srchRes = StringInStr(FileReadLine(@ScriptFullPath, $ln), $strRes) If $srchRes > 0 Then $lr = $ln ExitLoop EndIf Next $strRes = '#AutoIt3Wrapper_Res_Field=Release date|' For $ln = $lr To $lr + 16 $srchRes = StringInStr(FileReadLine(@ScriptFullPath, $ln), $strRes) If $srchRes > 0 Then $lnRes = $ln ExitLoop EndIf Next $rd = FileGetTime(@ScriptFullPath, 0, 0) _FileWriteToLine(@ScriptFullPath, $lnRes, '#AutoIt3Wrapper_Res_Field=Release date|' & $rd[2] & '.' & $rd[1] & '.' & $rd[0], 1) Global $dateRlse = $rd[2] & '.' & $rd[1] & '.' & $rd[0] FileSetTime(@ScriptFullPath, $rd[0] & $rd[1] & $rd[2] & $rd[3] & $rd[4] & $rd[5], 0) EndFunc ;==>FileInfo FileWriteToLine_bug_Au3.3.9.20+.au3