What is the script for selecting a specific word in a field?
Ken Ray
kray at sonsothunder.com
Wed May 18 12:34:26 EDT 2005
On 5/18/05 10:44 AM, "Robert Ball" <reball at mac.com> wrote:
> 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.
Hey, Robert... welcome to the list! John Ridge gave you the answer that is
close to what I would have given you:
on tabKey
find word xxx in field "YourAnswer"
select the foundText
end tabKey
which causes Rev to find and put a box around the text, and then highlight
the text, removing the box. You *do* see the box appear very briefly, but
the end result is what you want. To make it cleaner, wrap this with "lock
screen/unlock screen":
on tabKey
lock screen
find word xxx in field "YourAnswer"
select the foundText
unlock screen
end tabKey
I think what Eric was trying to suggest to you is that since the Revolution
IDE is scripted in Transcript as well, and that the IDE is open for you to
look at how Runtime Revolution scripted it, many times you can look into the
scripts of the IDE to get the functionality you're looking for (or at least
a starting place from which you can modify the code to suit your needs).
In this case, the script editor windows have a Find feature that does what
you're looking for (type in text in the find field and click the Find
button, it highlights (but doesn't box) the found text). However to actually
get into the script to look at it is a bit convoluted (you need to set the
pref that Eric identified, open a script editing window, find out the name
of it, set it to topLevel so contextual menus will work on it, then use the
contextual menu to edit the card script, find the revFindNext handler, and
examine it), and the script doesn't use the "find word"/"select the
foundtext" solution presented above. Instead, it uses "offset" to locate the
word that should be selected, and then uses "select" to select a character
range in the field.
Both ways work, but the find/select is probably the simplest and easiest.
Keep posting your questions to the list; we have a great bunch of people
here who are extremely helpful.
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list