Basic field word count question
Jan Schenkel
janschenkel at yahoo.com
Sun Nov 21 14:46:44 EST 2004
--- "Salinas, Ruben (GE Healthcare)"
<Ruben.Salinas at med.ge.com> wrote:
> My apologies for the simplicity of the question, but
> I'm just starting out with RunRev. Question is, how
> should I create a field on a card that displays the
> word count on a second field where the user is
> writing text? I would like the first field (word
> count) to recalculate automatically every time field
> 2 content changes.
>
> Thanks in advance for the replies.
>
> Harvjag
>
Hi Harvjag,
If you only want it recalculated after all changes
have been made, you'll want to do it on closeField :
--
on closeField
put the number of words of me into field "wordcount"
end closeField
--
If you want it updated as soon as the user hits a key,
the quick and dirty method would be on rawKeyDown :
--
local tUpdateFlag
on rawKeyDown
-- check if we haven't queued an update yet
if tUpdateFlag is not "true" then
send "UpdateWordCount" to me in 10 milliseconds
end if
-- let the event be handled the normal way
pass rawKeyDown
end rawKeyDown
on UpdateWordCount
put the number of words of me into field "wordcount"
-- don't forget to update the internal flag
put false into tUpdateFlag
end UpdateWordCount
--
The above method should cut down on the number of
updates, without the user noticing the delay.
Hope this helped,
Jan Schenkel.
=====
Join us at the European Revolution Conference
November 14-16, MALTA. ~ http://TechieTours.com/Rev/
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the use-livecode
mailing list