• Welcome to Valhalla Legends Archive.
 

Parsing the colors

Started by Networks, May 04, 2004, 08:58 AM

Previous topic - Next topic
|

Networks

I need a little help trying to parse messages that have been tweaked so they allow your messages to be different colors. ( Trivia Bot does, Stealthbot can parse it. )

I am sorry I seem so newbish right, It's morning and I can't remember what this is called again.

I am not asking for an entire function just a little help. * Pretty sure you'll understand *

Noodlez

Colors from which client?

GoSuGaMING

hes talking about stracraft when you do ÁU the color displays Blue on the client he wants it where if the bot see's that then the "addc" for that text will  be blue

Newby

Split by Á

Then for each item in the array you split the message by, determine the color, and add the rest of that array item to the RTB.
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Networks

Quote from: Newby on May 04, 2004, 09:19 AM
Split by Á

Then for each item in the array you split the message by, determine the color, and add the rest of that array item to the RTB.

I understand arrays and such but how do I split all the word(s) with Á in front and add it to the array? Every single one and then have it also change it to actual colors in the Richtextbox?

Fr0z3N

#5
if (message.indexOf("Á") > 0) {
  String array[] = null;
   array = message.split("Á");
{

if instr(message, "Á") then
dim array() as string
array = split(message, "Á")
end if


Edit: Code tags.

Eli_1

#6
Just an extension to what fr0zen already posted.
NOTE: This code was untested and was found to not work. I've fixed the code and it can be found here.


'// Put me somewhere  :P
Const Message as String = "ÁUThis is an example string. ÁYBlah blah blah blah blah (more useless text). ÁRInsert some retarded comment here. ÁVBlah blah blah blah blah." & vbCrLf
'/* This example will Split this string. */

Dim ColorParse() as String
'/* MerF!? */

Dim ColorByte as String
'/* This is just to make the code a little
'** easier to read. */

If InStr(1, Message, "Á", vbTextCompare) <> 0 Then
   ColorParse = Split(Message, "Á")
   For i = 0 to UBount(ColorParse)
       ColorByte = Left(ColorParse(i), 1)
       ColorParse(i) = Right(ColorParse(i), Len(ColorParse(i) - 1)
       AddText txtOutput, GetColor(ColorByte), ColorParse(i)
   Next i
End If




GetColor()

Public Function GetColor(byval ColorByte as String) as vbColorConstants
'// I think it's vbColorConstant. It might be different :P
Select Case ColorByte
. . .
End Select
. . .
End Function

Networks


Networks

#8

Dim ColorParse() As String
'/* MerF!? */

Dim ColorByte As String
Dim i As Integer
'/* This is just to make the code a little
'** easier to read. */

If InStr(1, Message, "Á", vbTextCompare)  0 Then
   ColorParse = Split(Message, "Á")
   For i = 0 To UBound(ColorParse)
       ColorByte = Left(ColorParse(i), 1)
       ColorParse(i) = Right(ColorParse(i), Len(ColorParse(i) - 1))
       'AddText txtOutput, GetColor(ColorByte), ColorParse(i)
   Next i
End If


its says

variable required - can't assign to this expression
at:
ColorParse(i) = Right(ColorParse(i), Len(ColorParse(i) - 1))

Why?

Eli_1

Quote
at:
ColorParse(i) = Right(ColorParse(i), Len(ColorParse(i) - 1))
Ya, that's my bad. I wrote that code on the fly when I was posting and never tested it. That's happening because of a mis-placed parenthasis.

Fixed.

ColorParse(i) = Right(ColorParse(i), Len(ColorParse(i)) - 1)


BaDDBLooD

I was looking at this, and i placed a message box after:



   If InStr(1, Message, "Á", vbTextCompare) = 1 Then

[/vbcode]

and friend said something with Á message box didn't go off
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

FuzZ

#11
Quote from: BaDDBLooD on May 04, 2004, 06:52 PM
I was looking at this, and i placed a message box after:



   If InStr(1, Message, "Á", vbTextCompare) = 1 Then

[/vbcode]

and friend said something with Á message box didn't go off



If InStr(Message, "Á", vbTextCompare) >= 1 Then
    MsgBox "Found Á"
end if

If InStr(Message, "Á", vbTextCompare) <> 0 Then
   MsgBox "Found Á"
end if


Edit> added the latter.

Eli_1

#12

If InStr(Message, "Á", vbTextCompare) >= 1 Then
   MsgBox "Found Á"e
end if


That's not the syntax InStr takes.
It should be InStr(Start, S1, S2, Seach type).
Your doing InStr(S1, S2, Search type).

This should work:

InStr(1, Message, "Á", vbTextCompare) >= 1 Then
   MsgBox "Found Á"e
end if



And to BaDDBLooD,
If InStr(1, Message, "Á", vbTextCompare) = 1 Then.
InStr returns the first instance of the "search string" (Á in this instance). That's why you do <> 0. InStr can return any number greater than 0, and less than or equal to Len(Message) -- depending on where in the string Á is.


BaDDBLooD

#13
yeah it still doesn't work

EDIT: Actually... the InStr function has NEVER worked for me... ;[
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Eli_1

#14
If InStr(1, Message, "Á", vbTextCompare) returns 0, then 'Message' doesn't contain that character...

And I just tryed testing the code I wrote, and there's more than 1 error. I'm fixing it right now -- I'll post when I finish.

|