Results 1 to 4 of 4

Thread: Parsing Ascii Colour Codes (they look like this --> )

  1. #1

    Thread Starter
    Lively Member esmerelda's Avatar
    Join Date
    Sep 2002
    Location
    South Croydon, UK
    Posts
    68

    Parsing Ascii Colour Codes (they look like this --> )

    Does anyone know of a way to parse incoming text for ascii colour codes ( for example which is red) so that all text that follows the code is a certain colour? I.E, the MUD server at the other end which sends me the text with the codes in it sends:

    | "Dream the dream and let it come true..." |


    which should, when parsed, show the following:

    | "Dream the dream and let it come true..." |

    Any ideas? The source is downloadable from http://members.lycos.co.uk/vinarianl.../esmud_src.zip and the compiled version from http://members.lycos.co.uk/vinarianlegends/esmud.zip. If you can help, it'd be appreciated.

    Oh, and while I remember, there's an annoying problem with that code where it adds a CrLf at the end of every line, but I don't want it to, because then you get loads of blank lines. If oyu run the prog, you'll see what I mena, but anyway, is there a way to search the incoming text line by line and remove the crlf fromthe end of each line? The server sends its text in UNIX format if that's any help... I got around that by using RTF boxes instead of normal text boxes, but it doubles the CrLf's rather than completely ignoring them. I'm confusing myself to...

    Ben.

    P.S. The source is based heavily on a tutorial from www.vbip.com, so no moaning about "Oh, you didn't write all of this", because I know I didn't, OK? I didn't know much about WinSocks until last night. *pokes*

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    You should do a function that passes over the recieved text and detect the colors in their special signs ().

    I hope it helps,
    Arie.

  3. #3

    Thread Starter
    Lively Member esmerelda's Avatar
    Join Date
    Sep 2002
    Location
    South Croydon, UK
    Posts
    68
    I've tried that, but I can't get it to read from the escappe sequence (the square and [) to the 'm'. It either reads too much or too little...

  4. #4
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    One time I attempted to write a mud client as well. I used a richtextbox to display colors. I was able to extract colors from the data. I stopped developing this client, because every time I wanted to add a new line, the rtf-box "flashed" (jumped to the start of the box, and then back to the end). It drove me nearly mad A while later I stopped mudding as well.
    I've attached the code to this post. It's in VB, and you're free to use code whatever you want. I hope it will help you.

    Good luck!
    Attached Files Attached Files

Posting Permissions

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



Click Here to Expand Forum to Full Width