SelectedChunk

Warren Kuhl warrenkuhl at gmail.com
Mon Sep 27 10:40:31 EDT 2010


Mike,

Thank you very much for this.  I really appreciate it.  Looks exactly like
what I was looking for.

You mentioned forcing only whole words.  Is this a command?  Or something I
would need to program?

Thanks again!
Warren




On Mon, Sep 27, 2010 at 9:21 AM, Mike Bonner <bonnmike at gmail.com> wrote:

> I'm positive this can be shortened, but as is should do what you want. It
> could be simplified greatly of course if you are forcing only whole word
> selections, but this will account for partial word selects, and also just
> an
> insertion point.
> *
> on mouseUp
>   -- Determine if there is actually a selection of more than 1 char
>   if word 2 of the selectedchunk - word 4 of the selectedchunk < 0 then
>      put word 2 of the selectedchunk into tChar
>   else
>      put word 4 of the selectedchunk into tChar
>   end if
>
>   -- Determine if the selection is already on a word boundary.
>   --if so determine which word the break is at.
>   if char tChar of field 1 is space then
>      put true into tCharMatch
>      put char 1 to tChar of field 1 into tTmp
>      put"Word: " & the number of words  in tTmp + 1 into tWord
>   end if
>
>   -- if a match hasn't been found yet, and we're not at the field start
>   -- nudge 1 char left and check for word break. Repeat until top of field
> or match
>   repeat while tChar > 1 and tCharMatch is empty
>      subtract 1 from tChar
>      if char tChar of field 1 is space then
>         put true into tCharMatch
>         put char 1 to tChar of field 1 into tTmp
>         put "Word: " & the number of words in tTmp + 1 into tWord
>      else if tChar = 0 then
>         --if we reach the start of the field, must be the first word
>         put "Word: 1" into tWord
>      end if
>   end repeat
>
>  answer information tWord
> end mouseUp*
>
> On Mon, Sep 27, 2010 at 7:17 AM, Warren Kuhl <warrenkuhl at gmail.com> wrote:
>
> > Is there an easy way to retrieve the word # of a field based on the
> > SelectedChunk?  The SelectedChunk contains the start/end position of a
> word
> > of a field.  Just am trying to determine which word without to much
> > coding...if possible.
> >
> > Thanks for any help!
> > Warren
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the Use-livecode mailing list