Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
from letside, furthest and closest line in multiline string
#1
Sorry for this simple question.

I want to get the line number of the line that is placed the most furthest away from the leftside
I want to get the line number of the line that is placed closest to the leftside
 
Code:
Copy      Help
         a
              b1
              b2
    c1
    c2



c1 = closest (first occurrence)
b1 = furthest (first occurrence)

The script I am using this in, will fetch selected text from anywhere where text can be selected.
This script then needs to know which line closest and which line is furthest.

Application examples: notepad, notepad++, QM,.... anywhere text can be selected.

The problem is (if tabs used) tab-values can differ from each application.
The empty leftside part of a line can contain spaces and/or tabs.

Again, sorry it seems stupid simple....I'm probably missing something.
#2
try this Ron
Code:
Copy      Help
str test1 test2=
;;;;;;;;;a
;;;;;;;;;;;;;;b1
;;;;;;;;;;;;;;b2
;;;;c1
;;;;c2

int j closest furthest lineC lineF
str c f
for j 0 2000000000
,if(test1.getl(test2 -j)<0) break ;;no more
,if(test1.len=0) continue ;;skip empty
,if j=0
,,closest=test1.len; furthest=test1.len
,,c=test1; f=test1;lineC=j; lineF=j
,else
,,if test1.len < closest
,,,closest=test1.len; c=test1; lineC=j
,,if test1.len > furthest
,,,furthest=test1.len; f=test1; lineF=j
out F"closest = {c.trim} on line {lineC+1} furthest={f.trim} on line {lineF+1}"
#3
This works!
Thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)