Hi, one question, please...
Is there any instruction to get the original text (unformatted) from a HTMLText?
Thank you very much.
How to get the original text from a HTMLText?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to get the original text from a HTMLText?
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to get the original text from a HTMLText?
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.
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.
