|
Samus Novice
Joined: 01 Jan 2003 Posts: 32
|
Posted: Fri May 14, 2004 8:57 pm
finding an item |
I've tried and tried to do this, but still can't figure it out.
How can you use a command that searches through the db and displays a box of the list of names it found and than you click the one you want and it shows the info of that? |
|
|
|
Rorso Wizard
Joined: 14 Oct 2000 Posts: 1368
|
Posted: Fri May 14, 2004 10:54 pm |
quote: Originally posted by Samus
I've tried and tried to do this, but still can't figure it out.
How can you use a command that searches through the db and displays a box of the list of names it found and than you click the one you want and it shows the info of that?
Something like this perhaps:
Code: |
#ALIAS map {
; %1 = listName
; %2 = function to perform
result=""
#forall %1 {#additem result %eval( %2)}
}
#ALIAS dblookup {
; %1 = keyword
res=%find( %1)
map @res %concat( %db( %i, "Name"), ":", %db( %i, "Num"))
choice=%pick( 'p:Select an item|o:1', @result)
#showdb %dbget( @choice)
}
|
Example:
dblookup Test
This searches the first column of the database after Test. Then it shows a picklist with the name of each entry. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri May 14, 2004 11:14 pm |
Use your query to build a list of items, then use that list as a picklist.
#VAR Pick {o:1}
#FORALL %query( %begins( &Name, A)) {#ADDI Pick {%db( %i, Name):%i}}
#SHOWDB %pick( @Pick) |
|
|
|
Samus Novice
Joined: 01 Jan 2003 Posts: 32
|
Posted: Sun May 16, 2004 5:26 am |
hmm, neither of these seem to work
they show the picklist but shows nothing on them. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun May 16, 2004 7:08 pm |
#VAR Pick {o:1}
#FORALL %query( %begins( &Name, A)) {#ADDI Pick {@{%{i}.Name}:%i}}
#SHOWDB %pick( %replace( @Pick, ",", " "))
This will give you all items in the database whose names begin with a capital A.
EDIT: Fixed typo! |
|
|
|
Samus Novice
Joined: 01 Jan 2003 Posts: 32
|
Posted: Sun May 16, 2004 8:14 pm |
hrmph, do you know why it still shows nothing in the picklist box
It has "clear" values, you can select the item you want but you don't know what it is, than when you click it, it displays everything perfectly |
|
|
|
Rorso Wizard
Joined: 14 Oct 2000 Posts: 1368
|
Posted: Sun May 16, 2004 9:22 pm |
quote: Originally posted by Samus
hrmph, do you know why it still shows nothing in the picklist box
It has "clear" values, you can select the item you want but you don't know what it is, than when you click it, it displays everything perfectly
Both triggers assume there is a Name field in the database. If there is none the picklist will appear empty. The Name field is what they show or should show in that list. |
|
|
|
Samus Novice
Joined: 01 Jan 2003 Posts: 32
|
Posted: Sun May 16, 2004 10:15 pm |
There is a name field
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun May 16, 2004 10:39 pm |
No, I don't know why you don't see any names in your picklist. I see them in mine.
|
|
|
|
|
|