Autofill for Text Entry Responses

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lrieber
Posts: 40
Joined: Sat Sep 24, 2011 6:30 pm
Contact:

Autofill for Text Entry Responses

Post by lrieber » Tue Nov 26, 2013 7:19 pm

Hello everyone,

I created an autofill function for a text response as part of an instructional game that one of my students at the University of Georgia is currently making.

I think it is pretty cool and I've not seen any other postings about such a function in any of the forums.

To learn more about it and to get a demo file with code that you are more than welcome to take and adapt, go to my blog entry where I write about it:

http://learninglivecode.blogspot.com/20 ... entry.html

(And, if just one person accesses my blog, you will have increased my readership by 100%.)

Lloyd Rieber

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: Autofill for Text Entry Responses

Post by dunbarx » Tue Nov 26, 2013 7:32 pm

Hi.

The next person in will only increase your readership by 50%.

You have made what I always referred to as a binary search, not really an autofill. When I get home tonight I will post a handler I used on a recent project. It handles deletes.

Craig Newman

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Autofill for Text Entry Responses

Post by Mark » Wed Nov 27, 2013 3:45 am

Lloyd,

Your readership increased by 50%.

It strikes me that you don't use the filter command.

kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: Autofill for Text Entry Responses

Post by dunbarx » Wed Nov 27, 2013 5:14 am

Hi again.

Make a field "outPutField" and another field to enter the text to find. I had this in the entry field script:

Code: Select all

on keyDown var
   put var after me
   if the length of me > 2 then put revFullFind(me,yourList) into fld "outputField"
   else put "" into fld "outputField"
end keyDown

on backspacekey
   delete the last char of me
send "keydown" to me
end backspacekey

function revFullFind tFind,tData
   repeat for each line tLine in tData
      if tFind is in tLine then put tLine & return after temp
   end repeat
   return char 1 to -2 of temp
end revFullFind
"yourList" is a return delimited list of text. You will see that as you type, matches appear, and are winnowed as more chars are entered. Deleting chars reverses the process. This can be modified as needed.

But Mark makes a point. The "filter" command has much power within it.

Craig Newman

lrieber
Posts: 40
Joined: Sat Sep 24, 2011 6:30 pm
Contact:

Re: Autofill for Text Entry Responses

Post by lrieber » Wed Nov 27, 2013 6:28 pm

Craig and Mark,

Many thanks for your posts. I did not know about the "filter" command.

And, just adding the on backspacekey code makes my own program now function properly.

@Mark: I took a look at your new book. I'll be buying a copy to review -- it may be perfect for some of the courses I teach here at the University of Georgia.

Lloyd

Post Reply