how to set the textStyle of word 1 of the selection?

BNig niggemann at uni-wh.de
Mon Mar 15 09:43:53 EDT 2010


André,

this works most of the time, since a user can select into spaces, returns
and tabs etc.
This assumes that a real word starts with an ASCII value below 48. So many
of the interpunctation is in that range, but not all.
--------------------------------
on mouseUp
   put the selectedChunk into tSelect
   put field 1 into tData
   -- no selection made of just a click into the field 
   if tSelect is "" or word 4 of tSelect < word 2 of tSelect then exit
mouseUp
   
   put word 2 of tSelect into tStartChar
   put word 4 of tSelect into tEndChar
   
   put tStartChar into tBeginOfWord
   
   -- selection can start with space, return or other non-letters
   -- the test for number of words later on would return 
   -- the word before the intended word
   repeat with i = tStartChar to tEndchar
      if chartoNum (char i of tData) > 47 then 
         exit repeat
      else
         add 1 to tBeginOfWord
      end if
   end repeat
   
   -- 
   if tBeginOfWord <= tEndchar then
      set the textstyle of word  (the number of words of char 1 to
tBeginOfWord of tData) of field 1 to "link"
   else 
      -- optional
      answer "please include at least part of a word in the selection"
   end if
   
end mouseUp
-----------------------
may be there is a smarter way.
regards
Bernd
-- 
View this message in context: http://n4.nabble.com/how-to-set-the-textStyle-of-word-1-of-the-selection-tp1593292p1593371.html
Sent from the Revolution - User mailing list archive at Nabble.com.



More information about the use-livecode mailing list