Page 1 of 1

How to get the original text from a HTMLText?

Posted: Sun May 08, 2016 5:28 pm
by Fermin
Hi, one question, please...
Is there any instruction to get the original text (unformatted) from a HTMLText?
Thank you very much.

Re: How to get the original text from a HTMLText?

Posted: Sun May 08, 2016 7:04 pm
by FourthWorld
Set the htmlText of a spare field, then get the field's text. You can use the templateField if you don't have a spare field object.

Re: How to get the original text from a HTMLText?

Posted: Sun May 08, 2016 7:42 pm
by Fermin
Thank you, FourthWorld...
Well, it is not a critical issue because I had already solved with two fields.

In my test example:

I have a field ("MyField") with a text with words of different colors and need:
1) Save this text
2) Clean the field (or maybe write it any other text, etc. etc...)
3) Recover the original text in the same field with the same format (colors etc.)

I get it using two containers: one named "tP" to the plain text and another named "tH" for the HTML version. I have prepared a button with two options: 'Preserve' and 'Restore' and the system works well. The script is this:
--------------
on menuPick pItemName
   pItemName switch
      case "Preserve"
         put fld "myField" into fld "tP" - Plain Text
         put the htmlText of fld "myField" into fld "tH" - Text HTML
         -
         put "" into fld "MyField"
         -
         break
      case "Restore"
         put fld "tP" into fld "myField" -
         Set the htmlText of fld "myField" to fld "tH"
         break
   end switch
end menuPick
-----------------

It works well but, as the HTMLText format contains all the information, I thought that, maybe, there is an instruction to directly extract the plain text, and thus, use only one field.
Anyway, thanks again, FourthWorld for your quick help. :D