Jump to content



Photo

_FileRemoveLine


  • Please log in to reply
2 replies to this topic

#1 yehia

yehia

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 274 posts

Posted 07 April 2009 - 04:49 PM

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





#2 Jos

Jos

    oh joy ...

  • Developers
  • 21,047 posts

Posted 07 April 2009 - 05:29 PM

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

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#3 yehia

yehia

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 274 posts

Posted 07 April 2009 - 11:16 PM

oh i remember it was adding a @crlf so it wasnt removing the line but just making it empty




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users