au3scr Posted July 8, 2008 Share Posted July 8, 2008 I am trying to create file (Save as button on my guy) and i want save new file and create it only with some lines.its hard to describe it.I am trying to explain... When i made save button that simply overwritten lines in old file then it worked that way.Then I added save as button that must create new file,I creates new file but my problem is that my script wont write any lines on that new file that made with save as button from gui. 1st I tried: _FileCreate($filename&".lua"); I didnt have that with save button.I added this for save as button $IsSelected = GUICtrlRead ($orb); == > $orb is check box If $IsSelected = 1 Then $IsSelected = 'loadfile(dir .. "other\\orb.lua")()' ; == > If check box is selected then write this line If $IsSelected = 4 Then $IsSelected = '--loadfile(dir .. "other\\orb.lua")() ; == > If check box is not selected then write this line _FileWriteToLine($filename&".lua",55,$IsSelected,0) ; == > ok here I am trying to write 55 th line for file, but this script creates new empty file but it dont write any text on 55 th line How i can write that 55 th line when i tell script to make new file? I need write specific line in new freshly created file. Link to comment Share on other sites More sharing options...
au3scr Posted July 8, 2008 Author Share Posted July 8, 2008 I tried make it more simple. so how i can make it write lines int that file? #include <File.au3> ;Example: Write to line 3 of c:\test.txt REPLACING line 3 _FileCreate("c:\test.txt") _FileWriteToLine("c:\test.txt", 3, "my replacement for line 3", 1) ;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3 _FileWriteToLine("c:\test.txt", 3, "my insertion", 0) Link to comment Share on other sites More sharing options...
sandin Posted July 8, 2008 Share Posted July 8, 2008 I'm not sure you can replace a line that doesn't exist, so you should create line 3 first: #include <File.au3> $file = "c:\test.txt" $file_open = FileOpen($file, 1) for $i = 1 to 2 FileWriteLine($file_open, $i); you can make "" instead of $i, to make the lines blank. Next FileClose($file_open) MsgBox(0, $file, "the specified file now counts 3 lines," & @CRLF & "press OK to rename line 3") _FileWriteToLine($file, 3, "my replacement for line 3", 1) Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
au3scr Posted July 8, 2008 Author Share Posted July 8, 2008 Tnx it worked great muttley 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