Jump to content
Sign in to follow this  
yehia

_FileRemoveLine

Recommended Posts

yehia

this is an easy function for line removing since i didnt find any when i was looking for one

i know this may be simple but it can save time for some ppl out there and one more topic wouldnt hurt anyone :D

Func _FileRemoveLine($sFile, $iLine)
    $aFile = FileOpen($sFile,0)
    Local $filtxt = FileRead(aFile, FileGetSize($sFile))
    $filtxt = StringSplit($filtxt, @CRLF, 1)
    If UBound($filtxt, 1) < $iLine Then Return SetError(1, 0, 0)
    FileClose($aFile)
    Local $fil = FileOpen($sFile, 2)
    If $fil = -1 Then Return SetError(3, 0, 0)
    For $i = 1 To UBound($filtxt) - 1
        If $i = $iLine Then
            FileWrite($fil, "")
        ElseIf $i < UBound($filtxt, 1) - 1 Then
            FileWrite($fil, $filtxt[$i] & @CRLF)
        ElseIf $i = UBound($filtxt, 1) - 1 Then
            FileWrite($fil, $filtxt[$i])
        EndIf
    Next
    FileClose($fil)
    Return 1
EndFunc   ;==>_FileRemoveLine

GL all

Share this post


Link to post
Share on other sites
Jos

this is an easy function for line removing since i didnt find any when i was looking for one

Remarks

If _FileWriteToLine is called with $fOverWrite as 1 and $sText as "", it will delete the line.

:D

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×