realbasic-nug
[Top] [All Lists]

PARSING TEXT AND REMOVING PARSING TAGS

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: PARSING TEXT AND REMOVING PARSING TAGS
From: beto <beto at epicodeinteractive dot com>
Date: Thu, 30 Dec 2004 17:03:06 -0600
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Hello everyone ( Sorry for posting again, but I don't seem to get it working) ,


I have the following code in a method. The code works great, but after parsing the text it leaves the parsing tags. My question, how can I remove the parsing tags without losing the style of the text.

For example I have the following text:

<u>You are the searcher</u>

<b>This text is bold.</b>
<i>anyone from Italy</i>
<u>A little Underline here</u>


My code parses the text by making bold what needs to be bold and underline what needs to be underline. My problem is removing the <b> tag and the rest of the tags. I used the replace function and passed it to an editfield. When I use this method the text looses its style. I thought of creating a styleText variable and then pass my style text to that variable. I then try to pass the style text back to the editfield thinking it would keep its style, but it did not work. I got errors.

Thanks for your time.

This is my code.

bchar = beginning character
echar = ending character



Sub parseStyleTextI(thefield as editfield, bchar as string, echar as string)


 dim x1pos, x2pos as integer

  dim text as string

  text = thefield.text

  insert_pos = 1

  while insert_pos > 0

    if   InStr( insert_pos , text, bchar ) > 0 then

      x1pos = InStr( insert_pos , text, bchar ) + len( bchar ) -1

      x2pos = InStr( x1pos, text, echar ) -1

      thefield.StyledText.Size(x1pos, ( x2pos - x1pos ) ) = 14

      select case bchar

      case "<b>"

        thefield.StyledText.Bold(x1pos, ( x2pos - x1pos ) ) = true

      case "<i>"

        thefield.StyledText.italic(x1pos, ( x2pos - x1pos ) ) = true

      case "<u>"

        thefield.StyledText.underline(x1pos, ( x2pos - x1pos ) ) = true

      end Select




      'HERE I WANTED TO GET RID OF THE PARSING TAGS.

      thefield.text = Replace(text,bchar,"")

      thefield.text = Replace(text,echar,"")




      insert_pos = x2pos

    else

      insert_pos = 0

    end if


End Sub



Beto T.
+----------------------------------------------------------------------- ---------------------------------------------------------+ I can do everything (all things or all relevant matters) through HIM (Jesus Christ) who
gives me strength.
Philippians 4:13 +----------------------------------------------------------------------- ---------------------------------------------------------+
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>