slowness of "on keyUp" script

Peter M. Brigham pmbrig at gmail.com
Sun Jul 1 13:09:46 EDT 2012


On Jul 1, 2012, at 12:31 PM, Mike Bonner wrote:

> Does this work better for you?
> 
> on keydown pKey
>   if the length of me < 9 and  pKey is a number then
>      pass keydown
>   else
>      beep
>   end if
> end keydown
> 
> command doHyphens
>   if not offset("-",me) then

This will be a problem: offset("-",me) will evaluate to a number but the "if" statement is looking for a boolean.

>      put "-" after char 5 of me
>      put "-" after char 3 of me
>   end if
> end doHyphens

Here's what I use:

on keyDown x
   if x is not in "0123456789" then
      beep
      exit keyDown
   end if
   if the number of chars of me is among the items of "3,7" then
      put "-" after me
   end if
   pass keydown
end keyDown

> On Sun, Jul 1, 2012 at 10:14 AM, Dr. Hawkins <dochawk at gmail.com> wrote:
> 
>> I' surprised at how slow this is--I can type fast enough to foul it.
>> 
>> American social security numbers have nine digits, with a dash after
>> the third and fifth.
>> 
>> I attached this to a field to handle it automatically
>> 
>> on keyUp theKey
>>   if the length of me = 3 or the length of me=6 then put "-" after me
>>   if theKey is among the chars of "0123456789" then
>>      pass keyup
>>   else
>>      beep
>>   end if
>> 
>> end keyUp
>> 
>> If I blast a bunch of numbers on the keyboard at once, I get extra
>> numbers before the hyphens: right now it shows 873124-6758021394
>> 
>> 
>> --
>> The Hawkins Law Firm
>> Richard E. Hawkins, Esq.
>> (702) 508-8462
>> HawkinsLawFirm at gmail.com
>> 3025 S. Maryland Parkway
>> Suite A
>> Las Vegas, NV  89109
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list