#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!
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 ?
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)
Hello, I just discovered bad thing. If I used _FileWriteToLine function in AutoIt3 beta since 126.96.36.199 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.188.8.131.52, line 677:
Local $aArray = StringRegExp(@CRLF & $sFileRead & @CRLF, "(*BSR_ANYCRLF)([^\R]*)(?:\R)(?:\R$)?", 3) v.184.108.40.206, 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 AutoIt220.127.116.11. #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 & '.' & $rd & '.' & $rd, 1) Global $dateRlse = $rd & '.' & $rd & '.' & $rd FileSetTime(@ScriptFullPath, $rd & $rd & $rd & $rd & $rd & $rd, 0) EndFunc ;==>FileInfo FileWriteToLine_bug_Au18.104.22.168+.au3
I'm trying to create/see if it's possible for an alternative to _FileWriteToLine with no memory limitation.
For example: >jchd's -_FileCountLines