poplist of alternative txt options in fld

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

poplist of alternative txt options in fld

Post by scotttyang » Fri Jun 04, 2010 5:44 pm

There is a important field feature I need to re-write an electronic medical record application at our medical clinic before we can consider purchasing Revolution (I have purchased Metacard and revolution Enterprise Years ago).

In a field, I would like a pop up list to begin showing (much like in the URL field of web browsers. For instance, as I type... (starting with two periods)

..amox

a field of possible choices comes up such as

..amoxicillin 400/5 1 tsp po bid f10
..amoxicillin 400/5 2 tsp po bid f10
..amoxicillin 600mg tab 1 tab po bid f10
..amoxicillin 500mg tab 2 tab po bid f10
..amoxicillin 200/5 1 tsp po bid f10

then I can keydown to select the proper formulation and dose of antibiotics.

This is an important feature that I couldn't figure out who to write for the old 2.6 runrev version


Scott Yang, M.D.
Valley Oaks Pediatrics Associates
www.valleyoakspediatrics.com

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: poplist of alternative txt options in fld

Post by bn » Fri Jun 04, 2010 7:10 pm

Hi Scott,

a while ago I did a stack that does a progressive search. It is by no means polished, but works ok. I uses around 1900 entries from the Rev dictionary.
It should give you an idea how to implement what you have in mind. If you have your data in a list, one entry per line, you could just paste it into the field "data", overwriting the existing data. Or you import your data. At present the import buttons take a text apart and put one word on one line. That is not what you want.
You type your search in the topleft field and the matches show up. You would have to adjust the script of the topleft field, I marked the relevant parts. (you would want the search that finds lines that start with your search, the way it is now the search finds first whole word matches and then the string at the beginning of the line.
The file format for stacks changed, if you are using 2.6.1 you might have problems opening the stack, I attach a version in legacy format also.
I attach the zipped stack.
progressiveSearch4OldFormat.rev.zip
legacy format
(14.99 KiB) Downloaded 265 times
progressiveSearch4.rev.zip
current format
(14.91 KiB) Downloaded 309 times
regards
Bernd

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: poplist of alternative txt options in fld

Post by FourthWorld » Fri Jun 04, 2010 8:29 pm

Scott -

Please drop me an email when you have a moment: ambassador@fourthworld.com

I have a question about your practice there in Modesto, and may be able to hook you up with some pediatric software.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: poplist of alternative txt options in fld

Post by dunbarx » Fri Jun 04, 2010 9:01 pm

Bernd knows what he is doing, and the stack he offers no doubt does also.

But just to get the idea across doesn't require much coding. Make two fields, one a simple editable field named "entryFld" and the other a scrolling list field named "dataFld". Put your data into fld "dataField". Set the textSize of fld "dataFld". Put this into the script of fld "entryField":

Code: Select all

local tData,tHeight

on openField
   put fld "dataFld" into tData
   put the textheight of fld "dataFld" into tHeight
end openField

on keyup tKey
   set the scroll of fld  "dataFld" to  lineoffset(me,tData) * theight - tHeight
end keyup

on backSpaceKey
   delete the last char of me
   set the scroll of fld  "medFld" to  lineoffset(me,tData) * theight - tHeight
end backSpaceKey
You can do it more compactly using "rawKeyUp" instead of "keyUp", losing the backSpaceKey handler. You can script the list field.

I wonder if your problem cannot best be solved with a simple combo box.

scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

Re: poplist of alternative txt options in fld

Post by scotttyang » Fri Jun 04, 2010 10:14 pm

Because in our clinic, we do type alot, at times we have short hand methods such as

"..tac" for triamcinolone apply to affected area tid for 5-7 days

or

"..zpak" for Zithromax 250mg 2 tab today and 1 tab po for days 2 to 5

doing the ..txt in a field allows us to select our short hand and populate our text easily. this behavior we see in Yahoo search or our URL fld in a brower where we can shorthand and able to select a much longer piece of text. having a popup list to be able to select as I write ..amox for different strengths in a field goes a long way!

Thanks for the feedback and shall try it. I had thought possibly since version 2.6 that this may have been an added feature.

Scott

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: poplist of alternative txt options in fld

Post by bn » Sat Jun 05, 2010 11:18 am

Scott,
I did not get that you wanted your shortcuts to show a selection while you were typing text in a field. If that is correct then I did a little stack that does that.

Since this field checks with each keystroke whether the word you are typing is one of your shortcuts there is a little overhead. But on my computer with a text of 3000 words this is not noticeable.

At the right you see the shortcuts, the format is: ".." & shortcut then a space and the text you would like to insert. Important: the shortcut has no space. Everything after the first space is taken as the text you want to insert. The format could easily be adapted to whatever you have as your data structure.

If you type into the left field and then you start typing .. as soon as you type yet another character a field pops up with the hits of the search, if any. If you click on a line in this pop up field this line will be inserted into your text, overwriting the search shortcut and the cursor will be placed after this insertion in your text field.

I tested this stack somewhat but not extensively. So there might be things that dont work as expected. If this is at all what you had in mind I think you can adapt this to your needs.

again I upload a stack in legacy and current file format.
typeInFieldAndFindText.rev.zip
current file format
(2.8 KiB) Downloaded 287 times
typeInFieldAndFindTextOldFormat.rev.zip
legacy file format
(2.84 KiB) Downloaded 292 times
regards
Bernd
PS please be careful with that placebollan :) or should that be placebollin?

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

Re: poplist of alternative txt options in fld

Post by Mark » Sat Jun 05, 2010 1:16 pm

Hi Scott,

Another solution that might be useful for you is SearchListLib. You can find it at the bottom of this website. The library contains a field object, which shows a custom popup menu. The list in the popup menu is filtered by the contents of the field while you're typing.

Best,

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

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: poplist of alternative txt options in fld

Post by doc » Sun Jun 06, 2010 12:03 am

Hey Scott,
I put together a very simple stack that "kind of" does what you are looking for:
http://www.docstoolchest.com/Predictive.rev

It's a bit "hackish" with the hidden fields and can probably be coded more elegantly, but filtering the text seems to do pretty well in my testing with Win 7. Although I haven't done so, you can probably grab the coordinates for the cursor position and have it pop up along side each time.

Hope that helps,
-Doc-


Edited for spelling

Post Reply