AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FileAppend

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
davidcphindex
Guest





PostPosted: Fri Jan 02, 2009 6:32 am    Post subject: FileAppend Reply with quote

Could someone tell me the quick and easy function for deleting an entire line of a file?

As in

Line1
Line2
Line3
Line4
Line5


... will look like:


Line1
Line4
Line5


after a command of

Delete textfile line 2
Delete textfile line 3

????



Is this standard and I'm just not seeing it?


thanks in advance...



david
Back to top
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Fri Jan 02, 2009 6:37 am    Post subject: Reply with quote

A simple one could look something like this, though not very efficient on large files.
Code:
DeleteLine(File, Line) {
   Loop, Read, %File%, %File%.tmp
      If A_Index not in %Line%
         FileAppend, %A_LoopReadLine%`n
   FileMove, %File%.tmp, %File%, 1
}
Call it with "DeleteLine(FileName, Lines)" where Lines is a comma-delimited list of the lines to be deleted (or just a single line).
_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
davidcphindex
Guest





PostPosted: Fri Jan 02, 2009 6:43 am    Post subject: Reply with quote

Thanks...


More involved than I would have thought, but this will do...


thanks for your help.



david
Back to top
Neight



Joined: 31 Dec 2008
Posts: 23

PostPosted: Fri Jan 02, 2009 8:42 am    Post subject: Reply with quote

Another perfect example of how no one searches the forum.
_________________
Ask stupid questions, get stupid answers.
Search before posting!
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7294
Location: Australia

PostPosted: Fri Jan 02, 2009 2:56 pm    Post subject: Reply with quote

Laod wrote:
Another perfect example of how no one searches the forum.
Wow, you found that without searching??? Wink Honestly, why search for something simple when you can write it yourself?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group