multiple-word phrases, links

Ken Ray kray at sonsothunder.com
Thu Sep 11 11:34:00 EDT 2003


> Here's a bit of code I use to do just that.
> 
> repeat for each line tPhrase in thePhrases]
>     if matchChunk(fld "MyText", "(" & tPhrase & ")", 
> tStartChar, tEndChar) then
>       set the textStyle of char tStartChar to tEndChar of fld 
> "MyText" to link
>     end if
> end repeat

Good suggestion, Chris. Just don't forget, Toma, to declare the
variables "tStartChar" and "tEndChar" as locals before you enter your
repeat loop. Otherwise you won't get anything back in those variables.

i.e. 

  local tStartChar,tEndChar
  repeat for each...

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/ 

> 
> Of course, you only have to use the repeat if you have 
> multiple phrases. The matchChunk function returns a Boolean 
> true or false if the text is found.  The parentheses are 
> necessary to match a patter of multiple words. The beginning 
> and ending characters are stored in whatever variables you 
> specify, in this case tStartChar and tEndChar.  So then you 
> just use those in a chunk expression to set your link.
> 
> Hope that helps.
> 
> Chris Sheffield
> Software Development
> Read Naturally
> csheffield at readnaturally.com
> 
> 
> -----Original Message-----
> From: use-revolution-admin at lists.runrev.com
> [mailto:use-revolution-admin at lists.runrev.com] On Behalf Of 
> Toma Tasovac
> Sent: Thursday, September 11, 2003 3:21 AM
> To: use-revolution at lists.runrev.com
> Subject: multiple-word phrases, links
> 
> Hi there.
> 
> I have a list containing various multiple-word phrases and I want 
> Revolution to find those phrases in a text field and turn them into 
> links (the whole phrase, not individual words).  What's the 
> best way of 
> doing this?  I can use wordOffset for each individual word in the 
> phrase and then make sure that the offsets are next to each other in 
> the text, but that sounds horrible.  There has to be a better way.
> 
> Helplessly yours,
> 
> Toma
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com 
> http://lists.runrev.com/mailman/listinfo/use-> revolution
> 
> 
> 
> _______________________________________________
> 
> use-revolution mailing list
> use-revolution at lists.runrev.com 
> http://lists.runrev.com/mailman/listinfo/use-> revolution
> 





More information about the use-livecode mailing list