Store formatted text in to variables
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Store formatted text in to variables
Hi
Is it possible to put the formatted text of a field into a variable and then put the variable content into another field with the same formatting?
Please take a look at the following screenshot 1. In field 1, the backgroundcolor of word 2 is yellow and planning to put this word 2 along with the formatting into a variable and put the variable into field 2 with same formatting like in the field 1 as shown in screenshot 2.
Thanking you in advance.
Screenshot 1 Screenshot 2 Regards
Dayakar
Is it possible to put the formatted text of a field into a variable and then put the variable content into another field with the same formatting?
Please take a look at the following screenshot 1. In field 1, the backgroundcolor of word 2 is yellow and planning to put this word 2 along with the formatting into a variable and put the variable into field 2 with same formatting like in the field 1 as shown in screenshot 2.
Thanking you in advance.
Screenshot 1 Screenshot 2 Regards
Dayakar
--
Thanks,
Dayakar N
Thanks,
Dayakar N
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Store formatted text in to variables
Err . . . I cheated
You can make things even shorter by changing the script to this:

Re: Store formatted text in to variables
Thank you very much Richmond for your alternative solution. The stack is helpful to know about clickText and the logic applied.
But good to know if there is an option to store the formatting info in the variable.
But good to know if there is an option to store the formatting info in the variable.
--
Thanks,
Dayakar N
Thanks,
Dayakar N
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Store formatted text in to variables
A variable can only store one value; and that would have to be eitheran option to store the formatting info in the variable
your string (the word) or the RGB code for the backGroundColor, it could not be both.
Re: Store formatted text in to variables
Thanks for the response.
Is there any option in LiveCode to find the position of the word pasted using a variable in field? So, that position could be passed into another variable and set the color of the pasted text by referring to word Position as shown in the following code (it is not working but just to give an idea).
Is there any option in LiveCode to find the position of the word pasted using a variable in field? So, that position could be passed into another variable and set the color of the pasted text by referring to word Position as shown in the following code (it is not working but just to give an idea).
Code: Select all
put the position of CT in fld "f2" into CTPosition
set the backGroundColor of word CTPosition of fld "f2" to KOLOR
--
Thanks,
Dayakar N
Thanks,
Dayakar N
Re: Store formatted text in to variables
HI dayakar,
to preserve formatting use "the htmltext of..." or "the rtftext of...".
Like this in your example:
...
set the htmltext of fld 1 to the htmltext of word 2 of fld 1
...
Best
Klaus
to preserve formatting use "the htmltext of..." or "the rtftext of...".
Like this in your example:
...
set the htmltext of fld 1 to the htmltext of word 2 of fld 1
...
Best
Klaus
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Store formatted text in to variables
It would be interesting @Klaus to know why LiveCode seems unable to set Italic text on Mac OS (no problem on Linux: dunno anent Windows).
Re: Store formatted text in to variables
No idea, works here in LC 9 dp6!
I used the LC "Text" menu for formatting.
I used the LC "Text" menu for formatting.
Re: Store formatted text in to variables
Thanks @Klaus it's working fine with htmlText.
--
Thanks,
Dayakar N
Thanks,
Dayakar N
Re: Store formatted text in to variables
Richmond.
I am still in v.6.7. I never noticed it before, but italic does not display correctly. The property sticks, just not the actual text. If it works in v9 as per Klaus, it might be interesting to see in which version it actually appeared, and if it was ever noted as such.
Craig
I am still in v.6.7. I never noticed it before, but italic does not display correctly. The property sticks, just not the actual text. If it works in v9 as per Klaus, it might be interesting to see in which version it actually appeared, and if it was ever noted as such.
Craig
Re: Store formatted text in to variables
Just tested with LC 8.1.4 RC1, same result as in the screenshot above, in other words it works as exspected!