09-08-2007, 05:00 PM
str a
a.getfile("$Desktop$\test.txt")
;a.RemoveLineN(4);; deletes line 5 from file
a.RemoveLineN(numlines(a)-1);; deletes last line of file
a.setfile("$Desktop$\test.txt")You must have Member function str.RemoveLineN
(To add new Member function) while QM window is active press and release (Ctrl+Alt+N) this will add a new Member function make sure you name the new Member function (str.RemoveLineN), and add the below code to it.
str.RemoveLineN
function# lineindex [nlines]
;Removes specified line(s).
;Returns index of first character of lineindex-th line, or -1 if lineindex is too big.
;lineindex - zero-based line index.
;nlines - number of lines to remove. Default or 0: 1 line.
;EXAMPLE
;str s="zero[]one[]two"
;s.RemoveLineN(1)
;out s
if(nlines<1) nlines=1
int i=findl(this lineindex)
if(i>=0) this.remove(i findl(this+i nlines))
ret i