Sign in to follow this  
Followers 0
MasterX

FileWrite

6 posts in this topic

#1 ·  Posted (edited)

Is it possible to do filewrite without deleting all the text and only be able to write at the end of the file ?

I want to write in line 2, but in line 1-11 is text, so i´m only be able to delete all the text when opening the file or write at the end of the file.

But i want only line 2 to be changed.

Edited by MasterX

Share this post


Link to post
Share on other sites



$filehandle = Fileopen(yourfile, 1)
Filewrite($filehandle, "some text at the end")
Fileclose($filehandle)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

I think you misunderstood me :P

I don´t want to write some text at the end.

I want to change a line which is already there without deleting the whole text.

Share this post


Link to post
Share on other sites

hmm

I believe the only possible thing that can be done is FileReadLine then replace it in the whole text and rewrite all the file


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

http://www.autoitscript.com/forum/index.ph...c=81010&hl=

_FileAppendToLine("filename", linenumber, "text you want added")

example:

_FileAppendToLine("test.txt", 2, "text you want added")


Func _FileAppendToLine($sFile, $sLine, $sString)
    Local $iRead, $aString, $iResult, $hFile, $i

    $iRead = FileRead($sFile)

    $aString = StringSplit(StringStripCR($iRead), @LF)
    If $aString[0] < $sLine Then Return SetError(1, 0, 0)

    $aString[$sLine] &= $sString

    For $i = 1 To $aString[0]
        $iResult &= $aString[$i] & @CRLF
    Next

    $hFile = FileOpen($sFile, 2)
    FileWrite($hFile, $iResult)
    FileClose($hFile)
EndFunc   ;==>_FileAppendToLine
Edited by onestcoder

Need a website: http://www.iconixmarketing.com

Share this post


Link to post
Share on other sites

Thanks champ

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0