Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get last 5 lines?
#1
I need to get the last 5 text lines, from something like this:
http://pastebin.com/raw.php?i=1B27wjfX

I need it to get the last 5 lines, so it out's:
WETYWTGG
45235TFH
EHRJF
HRTHYRT5
HFHFH6

More text would be added so I need it to get the last 5 lines regardless of what the last lines contain.

Would be great if you could help!
#2
Macro Macro1581
Code:
Copy      Help
str s=
;aaaa
;bbbbbbb
;cccccc
;dddddddd
;eeeeeeee
;ffffffff
;gggggggg
;hhhhhh

int n=numlines(s)
if(n>5) s.getl(s n-5 2)

out s
#3
Gintaras Wrote:Macro Macro1581
Code:
Copy      Help
str s=
;aaaa
;bbbbbbb
;cccccc
;dddddddd
;eeeeeeee
;ffffffff
;gggggggg
;hhhhhh

int n=numlines(s)
if(n>5) s.getl(s n-5 2)

out s

Thanks that helped a lot, now I'm having an issue with adding the list to my Listbox.

I've tried using:
LB_Add id(6 hDlg) s

But it doesn't add a linebreak in the list and displays as: WETYWTGG45235TFHEHRJFHRTHYRT5HFHFH6
Instead of:
WETYWTGG
45235TFH
EHRJF
HRTHYRT5
HFHFH6

Any help?
#4
You can use:

Code:
Copy      Help
[...]
str line
foreach line s
,LB_Add id(6 hDlg) line
[...]
#5
Lucas Wrote:You can use:

Code:
Copy      Help
[...]
str line
foreach line s
,LB_Add id(6 hDlg) line
[...]

Thanks a bunch bro, works perfectly!

Edit: Is there any way of refreshing the LB so all text in the list is removed from the dialog?
#6
SendMessage(id(6 hDlg) LB_RESETCONTENT 0 0) ----> remove all items from listbox.
#7
Lucas Wrote:SendMessage(id(6 hDlg) LB_RESETCONTENT 0 0) ----> remove all items from listbox.
Thanks for your help man! Smile


Forum Jump:


Users browsing this thread: 1 Guest(s)