Jump to content

file remove line inside txt


faustf
 Share

Recommended Posts

hi guy i  have  questions   :)

i  saw  is possible read line  by line ,  and write line  by line  , but  how  is possible cancel line  by  line ??

i must  write in the same line  a blank line ?? if  yes  what is  a command  for  tell at autoit  , blanck line??

thankz at all 

Link to comment
Share on other sites

Providing you know what line number, do as JohnOne suggested.

If not, then you may need to use line testing and writing to another file, which gets renamed to the original afterward.

With a uniquely named line, you could just use _ReplaceStringInFile

All options above, bearing in mind, what kylomas asked too.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

hi guy at end  i  have  birth this  code  , for me,  work good,  but  probably  is not good  style :D

if  someone  want  corret  is  welcome 

Func _File_DeleteLine_Shift($path, $line)

    If $line = "" Then
        $line = 1
    EndIf
    _FileReadToArray($path, $aArray)
    Local $iDelete = FileDelete($path)
    $file = FileOpen($path, 1)

    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    Else

        For $i = 0 To UBound($aArray) - 1 ; Loop through the array.

            If $i = $line Then
                ;MsgBox (0,'', $aArray[$i])
            Else
                If $aArray[$i] = 34 Then

                Else
                    FileWrite($file, $aArray[$i] & @CR)
                EndIf

            EndIf
        Next

    EndIf

    ; Close the handle returned by FileOpen.
    FileClose($file)
EndFunc   ;==>_File_DeleteLine_Shift 

thankz at  all 

Edited by faustf
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...