| View previous topic :: View next topic |
| Author |
Message |
davidcphindex Guest
|
Posted: Fri Jan 02, 2009 6:32 am Post subject: FileAppend |
|
|
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
|
Posted: Fri Jan 02, 2009 6:37 am Post subject: |
|
|
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 |
|
 |
davidcphindex Guest
|
Posted: Fri Jan 02, 2009 6:43 am Post subject: |
|
|
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
|
Posted: Fri Jan 02, 2009 8:42 am Post subject: |
|
|
Another perfect example of how no one searches the forum. _________________ Ask stupid questions, get stupid answers.
Search before posting! |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7294 Location: Australia
|
Posted: Fri Jan 02, 2009 2:56 pm Post subject: |
|
|
| Laod wrote: | | Another perfect example of how no one searches the forum. | Wow, you found that without searching??? Honestly, why search for something simple when you can write it yourself? |
|
| Back to top |
|
 |
|