What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Get the last line of a string of ... you guessed it, text.

MrBig

Member
Joined
Jan 25, 2010
Messages
419
Reaction score
5
Currently I am using this, that works correctly for GatherBuddy:

Code:
               string enteredText = myREALLYbigLog;
                string lastLine = enteredText.Substring(enteredText.LastIndexOf(Environment.NewLine) + 2);

but, for some reason doesnt work with honorbuddy


To help you help me, heres a bigger version of the code to find the last line, easier for debug:

Code:
                    string nl = Environment.NewLine; // same as "\n"
                    int nllen = nl.Length;
                    String s1 = enteredText;
                    string s2;
                    if (s1.LastIndexOf(nl) == s1.Length - nllen)
                        s2 =
                            s1.Substring(0, s1.Length - nllen).Substring(
                                s1.Substring(0, s1.Length - nllen).LastIndexOf(nl) + nllen);
                    else
                        s2 = s1.Substring(s1.LastIndexOf(nl) + 2);

                    lastLine = s2;


I open the HB log in Notepad++ and activated the glyphs view so that I could see the Carriage Returns + Line Feeds (CRLF for short), and they are there, so.. dont know whats up
 
Last edited:
And there it is :
Code:
            String s1 = richTextBox1.Text;
            string s2;
            s1 = s1.Substring(0,s1.LastIndexOf("\n"));
            s2 = s1.Substring(s1.LastIndexOf("\n"));
            s2 = s2.Trim();
            lastLine = s2;

Edit: after testing against a live feed from HB still gives me error... something is fishy :/
 
Last edited:
Lol... Honorbuddy log does not use \n or \r\n for new lines, but just \r ... how odd.
 
btw i am trying to reach you by pm , did you get any? i even replied on yours
 
btw i am trying to reach you by pm , did you get any? i even replied on yours

Please wait, I cant receive any PMs, i was told that there was a problem with my account beeing conflicting with another account, and i have asked it to be fixed, but i am still waiting.

It is not that i dont want to talk to you, i do. You can show up on live chat, and whisper me your msn email or something.
 
Back
Top