Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move the position of the multiline string
#4
little bit longer code this time

Code:
Copy      Help
str s ss
int i ii lines
foreach s _s
,if(ii=2) break
,if(!s.len)
,,ii+1
,if(ii=1)
,,ss.addline(s -1)
,,lines+1
,i+1
_s.RemoveLineN(i-lines-1 lines)
ss- "[]"; ss.rtrim
_s.addline(ss -1)
out _s

 also will need this member function

Member function str.RemoveLineN
Code:
Copy      Help
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


Messages In This Thread
RE: Move the position of the multiline string - by Kevin - 10-22-2022, 03:37 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)