Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Samus
Novice


Joined: 01 Jan 2003
Posts: 32

PostPosted: 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?
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: 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.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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)
Reply with quote
Samus
Novice


Joined: 01 Jan 2003
Posts: 32

PostPosted: Sun May 16, 2004 5:26 am   
 
hmm, neither of these seem to work
they show the picklist but shows nothing on them.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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!
Reply with quote
Samus
Novice


Joined: 01 Jan 2003
Posts: 32

PostPosted: 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
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: 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.
Reply with quote
Samus
Novice


Joined: 01 Jan 2003
Posts: 32

PostPosted: Sun May 16, 2004 10:15 pm   
 
There is a name field
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net