realbasic-nug
[Top] [All Lists]

Re: Parsing Text and Removing Parsing Tags

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Parsing Text and Removing Parsing Tags
From: Joshua Hawcroft <rblists at joshuahawcroft dot com>
Date: Fri, 31 Dec 2004 09:24:25 +1000
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <BBE6C7AA-5A92-11D9-95D1-000A9578809A at epicodeinteractive dot com>
Depending on what you're trying to do, you might like to take a look at:
http://www.domainsoftworx.com/#htmlfield


cheers,
Josh


On 31/12/2004, at 4:43 AM, beto wrote:


Hello everyone,


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>


_______________________________________________
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>