Merchants Posted October 23, 2010 Share Posted October 23, 2010 (edited) some how this does not work any one know why ? #include <File.au3> Global $sIniFile = FileOpen(@ScriptDir & "test.txt", 0) ;Example: Write to line 3 of c:\test.txt REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my replacement for line 3", 1) ;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my insertion", 0) Edited October 23, 2010 by Merchants Link to comment Share on other sites More sharing options...
Werty Posted October 24, 2010 Share Posted October 24, 2010 some how this does not work any one know why ? #include <File.au3> Global $sIniFile = FileOpen(@ScriptDir & "test.txt", 0) ;Example: Write to line 3 of c:\test.txt REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my replacement for line 3", 1) ;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my insertion", 0) Try putting a path in there. Untested: #include <File.au3> Global $sIniFile = FileOpen(@ScriptDir & "test.txt", 0) ;Example: Write to line 3 of c:\test.txt REPLACING line 3 _FileWriteToLine(@ScriptDir & "/" & $sIniFile, 3, "my replacement for line 3", 1) ;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3 _FileWriteToLine(@ScriptDir & "/" & $sIniFile, 3, "my insertion", 0) Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
MrMitchell Posted October 24, 2010 Share Posted October 24, 2010 some how this does not work any one know why ? #include <File.au3> Global $sIniFile = FileOpen(@ScriptDir & "test.txt", 0) ;Example: Write to line 3 of c:\test.txt REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my replacement for line 3", 1) ;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my insertion", 0) If you were just using FileWrite() or FileWriteLine()... In your FileOpen, your flag is 0 which means open the file in read-only mode. You need to use one of the write modes, check help file for reference. Also, @ScriptDir doesn't include a trailing backslash \ so you'll need to add one prior to "test.txt". But since you're using _FileWriteToLine() you would need to specify a hard path for the first parameter like Werty said, so just replace your Global $sIniFile line to: Global $sIniFile = @ScriptDir & "\text.txt" It would be more efficient to assign the file path to your $sIniFile variable then continue to use $sIniFile instead of the actual path every time you use the _FileWriteToLine function. Link to comment Share on other sites More sharing options...
Merchants Posted October 24, 2010 Author Share Posted October 24, 2010 tryed all 2 post but still does not work... Link to comment Share on other sites More sharing options...
taietel Posted October 24, 2010 Share Posted October 24, 2010 Try this: #include <File.au3> Global $sIniFile = FileOpen(@ScriptDir & "\test.txt",2) ;=== some lines of text to test: For $i=1 To 10 FileWriteLine($sIniFile,"This is line "&$i) Next FileClose($sIniFile) ;=== now your code: ;Example: Write to line 3 of c:\test.txt REPLACING line 3 _FileWriteToLine(@ScriptDir & "\test.txt", 3, "my replacement for line 3", 1) ;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3 _FileWriteToLine(@ScriptDir & "\test.txt", 3, "my insertion", 0) Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
UEZ Posted October 24, 2010 Share Posted October 24, 2010 (edited) #include <File.au3> Global $sIniFile = @ScriptDir & "\test.txt" ;Example: Write to line 3 of c:\test.txt REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my replacement for line 3", 1) ;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3 _FileWriteToLine($sIniFile, 3, "my insertion", 0) Br, UEZ Edited October 24, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
taietel Posted October 24, 2010 Share Posted October 24, 2010 Merchants, in your first script you have to pass the file (with path) to the _FileWriteToLine function, not the file handle. Second, the file must exists - see the @Error in case of failure (that's why I wrote a test file in the begining). SkysLastChance 1 Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Merchants Posted October 24, 2010 Author Share Posted October 24, 2010 i have the info i need here thx 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