Results 1 to 5 of 5

Thread: GetNick

  1. #1
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default GetNick

    The reason I didn't post this only in my function thread in members section is that the people who would really use this would most likely be Junior Members and registered users, who maybe enjoy cool small snippets like a function that frees you from parsing the nickname from your username.

    Anyhow, here it is:

    SCAR Code:
    program New;
    {.include SRL/SRL/Misc/ArrayLoader.scar}


    Function Capitalized(C: Char): Boolean;
    Begin
      Result := LowerCase(C) <> C;
    End;


    Function GetNick(Username: String; NickLength: Integer): String;
    Var
      Parts, validParts: TStringArray;
      z, q, w, i, c: Integer;
    Begin
      Parts := StrToStrArray(Username);
      SetArrayLength(validParts, GetArrayLength(Parts));
      For I := 0 To High(Parts) Do
        If Length(Parts[i]) >= NickLength Then
        Begin
          validParts[z] := Parts[i];
          z := z + 1;
        End;
      SetArrayLength(validParts, z);
      For I := 0 To Z Do
      Begin
        For C := 1 To Length(validParts[i]) Do
          If Not Capitalized(validParts[i][c]) Then
            If q <= 3 Then
              q := q + 1
            Else
              Break
          Else
            w := w + 1;
        If q >= NickLength Then
        Begin
          Result := Copy(validParts[i], w + 1, q);
          Exit;
        End;
      End;
    End;


    begin
      Writeln(GetNick('Ran2dom Name', 3));
    end.

    Capitalized: Boolean by Wizzup

  2. #2
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    SCAR Code:
    Function Capitalized(c: Char): Boolean;
    Begin
      Result := Lowercase(c) <> c;
    End;



    EDIT: This doesn't work for me.
    Writeln(GetNick('R A N D', 3));



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  3. #3
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    It's not made to get nicks with spaces, spaces are for nubs

  4. #4
    Join Date
    Jun 2007
    Posts
    785
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Looks nice, Learned something from it, thanks

    [22:20] <[-jesus-]> freddy, go uninstall yourself

  5. #5
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Nice

    I have a challenge. Make it find the *best* nicks possible. IE: Bobby Bobbins, best nick = obb (appears twice)
    Interested in C# and Electrical Engineering? This might interest you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. GetTraderName & GetNick
    By Kik in forum Research & Development Lounge
    Replies: 0
    Last Post: 11-27-2007, 01:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •