What is the script for selecting a specific word in a field?

Martin Baxter martin at materiaprima.fsnet.co.uk
Wed May 18 11:50:33 EDT 2005


Hello Robert,

If I understand right?, xxx in your script stands for the string you wish
to search for and select in field "YourAnswer"

I suspect the trouble may be that : find word "", is correct syntax but
select word "", is not.

You can do : select word 3 of field 1, but not : select word "John" of field 1

a possible alternative approach,

on tabkey
 put field "UserInput" into stringtofind
 if stringtofind is not empty then
   put offset(stringtofind,field "YourAnswer") into t_offset
   if t_offset > 0 then
     put the number of chars in stringtofind into t_length
     select char t_offset to (t_offset + t_length - 1)\
           of field "YourAnswer"
   end if
 end if
end tabkey

It is also possible (if a little tortuous) to roll-your-own "Find Again"
using the offset function, if that's what you need.

HTH

Martin Baxter

>Hello Eric from Paris, thank you so much for responding to my request
>for help. Apparently I did not make clear exactly what I want to do in
>my first message, so here is my second attempt.
>
>I have a field YourAnswer on a card with several instances of xxx. I
>want to press the tab key and have the cursor move to the next instance
>of xxx and also hilite the xxx. The script
>
>on tabKey
>   find word xxx in field "YourAnswer"
>end tabKey
>
>moves the cursor to the next xxx and draws an outline box around the
>xxx, but it doesn't hilite the xxx, which is what I want. I have to
>double click the found xxx to select it.
>
>I had hoped the script
>
>on tabKey
>   select word xxx in field "YourAnswer"
>end tabKey
>
>would work, but it doesn't. I must be doing something wrong.
>
>Robert
>
>PS -- this is my first message, I just joined the list yesterday. I
>hope this is how to respond to your message.
>
>
>
>
>Hi Robert,
>
>As usual, it is very interesting to think of "Is there such a script
>which do that in the IDE?"
>Lights!
>In any script window, the Find button does what I want ;-)
>
>So, check the revFindNext function in the script of the single card
>of any script window which is called by the Find button and adapt it.
>In order to open scripts in IDE windows, check the "Contextual menus
>work in Revolution windows" in the main pane of the Rev Prefs.
>Then use a right click to display the contextual menu in any IDE window.
>Exploring the IDE always gets you rich...
>
>Best regards from Paris,
>
>Eric Chatonet.
>
>Le 17 mai 05 à 23:05, Robert Ball a écrit :
>
> > I have a field YourAnswer with several instances of xxx. I want to
> > tab to each instance of xxx. The scripts
> >
> > on tabKey
> >   find word xxx in field "YourAnswer"
> > end tabKey
> >
> > and
> >
> > on tabKey
> >   find "xxx" in field "YourAnswer"
> > end tabKey
> >
> > work, but they give me an outline box around xxx, which is not the
> > same thing as selecting xxx, which hilites xxx.
> >
> > The analogous script
> >
> > on tabKey
> >   select word xxx in field "YourAnswer"
> > end tabKey
> >
> > does not work. Neither do
> >
> > on tabKey
> >   select word xxx of field "YourAnswer"
> > end tabKey
> >
> > or
> >
> > on tabKey
> >   select "xxx" of field "YourAnswer"
> > end tabKey
> >
>
>----------------------------------------------------------------_______________
>________________________________
>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