Displaying styled text

Sarah sarahr at genesearch.com.au
Wed Dec 4 19:44:01 EST 2002


I haven't tried this but it doesn't sound impossible. You will need to 
loop through your field a couple of times. First get the offset for 
"(", then the next offset for ")". This will give you 2 character 
numbers which you can use to set the style. The trick then is using the 
3rd parameter of the offset function to look for the next "("

Then you will have to loop through each word of the field checking if 
it is a number so you can set it to bold. If it is a number in 
brackets, do you want it set to bold & italic? If so, you will need to 
check the current textStyle before changing.

Here is an untested script which should get you started:

on mouseUp
	put 0 into skipChar
	repeat
		put offset("(", fld "Data", skipChar) into startChar
		put offset(")", fld "Data", skipChar) into endChar
  		if startChar = 0 or endChar = 0 then exit repeat

		set the textStyle of char startChar+skipChar to endChar+skipChar of 
fld "Data" to "italic"
		-- this includes the brackets
		put endChar into skipChar
	end repeat

	put 1 into wordCount
	repeat for each word w in fld "Data"
		if w is a number then
			-- not checking to see if it is already italic
			set the textStyle of word wordCount of fld "Data" to "bold"
		end if
		add 1 to wordCount
	end repeat
end mouseUp

Cheers,
Sarah


On Thursday, December 5, 2002, at 08:42  am, Toma Tasovac wrote:

> Dear List,
>
> I have a field which displays some text.  Is it possible to set the 
> textStyle of numbers to bold; and the textStyle of bracketed strings 
> to italics, so that the plain text actually gets displayed as:
>
> 1. (italic text) plain text blah-blah.  2. (italic text) plain text 
> blah-blah.
>
> All best,
> Toma
>
> _____________________________________
> Toma Tasovac
> Princeton University
> Department of Comparative Literature
> 318 East Pyne
> Princeton, NJ 08544
>
> ttasovac at princeton.edu
> ttasovac at post.harvard.edu





More information about the use-livecode mailing list