08-28-2007, 07:32 PM
What do you think of this ?
UPDATED
Member function str.RemoveLineN
UPDATED
int cnt;str ranlines linex lines=
;line0
;line1
;line2
;line3
;line4
;line5
;line6
;line7
;line8
out
rep
,if lines="";break
,cnt=Uniform(0 numlines(lines));if cnt=numlines(lines);cnt-1
,linex.getl(lines cnt)
,lines.RemoveLineN(cnt)
,ranlines.formata(linex)
,ranlines+"[]"
out ranlines
Member function 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