How to put a list into a field on a card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to put a list into a field on a card
I have a .txt file that is a list of items.
I want to put this list into a field on a card when the card is opened and as characters are typed into a search field only items in the .txt file that match are shown.
What I mean is that If the first character I type in is a "P" then only lines beginning with "P" are displayed in the List. Then if I type in an "o" only items beginning with "Po" are displayed.
I know this can be done but I don't know how.
Thanks
Tom
I want to put this list into a field on a card when the card is opened and as characters are typed into a search field only items in the .txt file that match are shown.
What I mean is that If the first character I type in is a "P" then only lines beginning with "P" are displayed in the List. Then if I type in an "o" only items beginning with "Po" are displayed.
I know this can be done but I don't know how.
Thanks
Tom
Re: How to put a list into a field on a card
Hi Tom,
Here is a stack that shows one way to do this. It uses the "colorNames" as an example.
It uses a display field "fList" for the filtered list and the whole list is stored as a custom property of that field.
Instead of a custom property you could use any other container to store the complete list that is filtered into the list field.
Kind regards
Bernd
Here is a stack that shows one way to do this. It uses the "colorNames" as an example.
It uses a display field "fList" for the filtered list and the whole list is stored as a custom property of that field.
Instead of a custom property you could use any other container to store the complete list that is filtered into the list field.
Kind regards
Bernd
- Attachments
-
- filterList.livecode.zip
- (4.97 KiB) Downloaded 26 times
-
- Livecode Opensource Backer
- Posts: 9864
- Joined: Fri Feb 19, 2010 10:17 am
Re: How to put a list into a field on a card
- Attachments
-
- DaftList.txt.zip
- Sample text File
- (653 Bytes) Downloaded 25 times
-
- Filtration.livecode.zip
- Stack
- (1.43 KiB) Downloaded 18 times
-
- Livecode Opensource Backer
- Posts: 9864
- Joined: Fri Feb 19, 2010 10:17 am
Re: How to put a list into a field on a card
I apologise unreservedly for spelling 'Piccalilli' wrongly:
https://en.wikipedia.org/wiki/Piccalilli
https://en.wikipedia.org/wiki/Piccalilli
Re: How to put a list into a field on a card
Hi Richmond,richmond62 wrote: ↑Wed Jan 29, 2025 1:24 pmI apologise unreservedly for spelling 'Piccalilli' wrongly:
https://en.wikipedia.org/wiki/Piccalilli
Thank you for making me aware of Piccalilli.
How about setting the script of field "Sieve" to
Code: Select all
on textChanged
local tWholeText, tfilteredText
put field "fGUFF" into tWholeText
filter lines of tWholeText with the text of me & "*"
put tWholeText into field "fFILTER"
end textChanged
Kind regards
Bernd
-
- Livecode Opensource Backer
- Posts: 9864
- Joined: Fri Feb 19, 2010 10:17 am
Re: How to put a list into a field on a card
Super Bernd.
But then I have always been the man who uses a SHOVEL to stir the sugar in his coffee, while you are the man with the refined silver spoon.
But then I have always been the man who uses a SHOVEL to stir the sugar in his coffee, while you are the man with the refined silver spoon.

Re: How to put a list into a field on a card
Hi Bernd and Richmond!
I appreciate your help, but I've not been able to make this work quite yet.
The problem I have is I have a text file with About 300 Items. One line per Item.
I need to load that file into a field where the user can then search for a particular
Item. The problem I have Is on fairly rare occasions each user of the app will need to
add one or more items to the list. I have included that ability in the App I have written.
I don't quite understand where the data in Bernd's example comes from, and I
don't want the user to be required to select a file in order to use it in Richmond's
example. I hope this is clear. I have been away from LC for a couple of years and am
a little rusty.
Thanks in advance for your help. I really do appreciate it.
Tom
I appreciate your help, but I've not been able to make this work quite yet.
The problem I have is I have a text file with About 300 Items. One line per Item.
I need to load that file into a field where the user can then search for a particular
Item. The problem I have Is on fairly rare occasions each user of the app will need to
add one or more items to the list. I have included that ability in the App I have written.
I don't quite understand where the data in Bernd's example comes from, and I
don't want the user to be required to select a file in order to use it in Richmond's
example. I hope this is clear. I have been away from LC for a couple of years and am
a little rusty.
Thanks in advance for your help. I really do appreciate it.
Tom
Re: How to put a list into a field on a card
If I understand your last post, assuming the field is locked, simply put this into its script:The problem I have Is on fairly rare occasions each user of the app will need to
add one or more items to the list.
Code: Select all
on mouseUp
put the text of me into origText
ask "enter new data"
if it <> "" and the result <> "Cancel" then
put return & it after origText
sort origText
put origText into me
end if
end mouseUp
Last edited by dunbarx on Mon Feb 03, 2025 3:11 pm, edited 1 time in total.
Re: How to put a list into a field on a card
Hi Tom,
I tried to adapt my stack to your specs.
It uses 2 fields: one is the complete list of entries that should probably be out of view. That list of entries is used to display the entries or the filtered entries.
I currently use the ColorNames to give the list some 500 entries to work with and see how it responds.
I added the option to add an entry to the complete list.
Clicking on the display list triggers a script for an action when the user clicks at the field, currently it displays the text of the clicked line.
See if it works for you.
Kind regards
Bernd
I tried to adapt my stack to your specs.
It uses 2 fields: one is the complete list of entries that should probably be out of view. That list of entries is used to display the entries or the filtered entries.
I currently use the ColorNames to give the list some 500 entries to work with and see how it responds.
I added the option to add an entry to the complete list.
Clicking on the display list triggers a script for an action when the user clicks at the field, currently it displays the text of the clicked line.
See if it works for you.
Kind regards
Bernd
- Attachments
-
- filterList2.livecode.zip
- (3.76 KiB) Downloaded 9 times