Autofill Utility

Bob Sneidar bobsneidar at
Thu Jan 23 16:32:32 EST 2020

Couple updates. I added a closeField handler to optionally add new entries to the uniqueValues property. Also rawKeyUp needs a delay so things like backspacing can work. 

on closeField
   put me into tValue
   put the uniqueValues of me into tUniqueValues
   if tValue is not among the lines of tUniqueValues then
      answer question "Add " & tValue & " to the Autofill list?" with "Cancel" or "Add"
      if it is "Add" then
         put cr & tValue after tUniqueValues
         sort lines of tUniqueValues
         set the uniqueValues of me to tUniqueValues
      end if
   end if
end closeField

ON rawKeyUp
  IF the text of me is not empty THEN
     wait 30 ticks with messages -- adjust to your liking
     autoFill the long id of me
     exit to top

  pass rawKeyUp
END rawKeyUp

Bob S

> On Jan 23, 2020, at 11:50 , Bob Sneidar <bobsneidar at> wrote:
> Hi all. 
> These scripts may help you if you want to autofill text in a field from a list of prior values. The rawKeyUp handler goes in the field, and the autofill can go anywhere in the message path. You can see how simple this is. 
> The prerequisite is to have a uniquevalues propery in the field. I have another handler if anyone is interested, which upon openCard queries a database for unique values for a list of fields, and then populates each field's uniquevalues property with the results, but I hesitate to put that handler here because it uses calls to sqlYoga, and some don't use that. 
> Enjoy! 
> Bob S
> ON rawKeyUp
>   IF the text of me is not empty THEN
>      autoFill the long id of me
>      exit to top
>      -- focus on me
>   END IF
>   pass rawKeyUp
> END rawKeyUp
> on autoFill pTargetID
>   put the text of pTargetID into tText
>   put the number of chars of tText into tCharCount
>   put the uniqueValues of pTargetID into tValueList
>   put lineOffset(tText, tValueList) into tOffset
>   if tOffset = 0 then exit autoFill
>   put line tOffset of tValueList into tNewValue
>   if tText is tNewValue then exit autoFill -- in case we tabbed
>   set the text of pTargetID to line tOffset of tValueList
>   select char tCharCount +1 to -1 of pTargetID
> end autoFill

More information about the use-livecode mailing list