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
Varinas
Newbie


Joined: 21 Aug 2002
Posts: 9
Location: USA

PostPosted: Sun Dec 01, 2002 1:36 pm   

Finding DB Records
 
Here is my alias:
#Alias identify {#FORALL %find( %1, Name) {say ~[Name: &Name~] ~[Value: &Value~] ~[Bonus: &Bonus~] ~[Weapon: &Weapon~] ~[Required: &Required~]}}

This is what it does, Lets say I type:
identify spear
it'll search the Name column for "spear" and then say the results...
Alright, for now i only have 2 database records, a wooden club, and a warped spear
when I type "identify club" it only says spear 2 times! I have no clue why... I tried a few things, none of which are any success. I would appreciate any help. Thank you.

Wake me up, I'm dead. Is it something that I said?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Dec 01, 2002 4:42 pm   
 
I don't see why it's finding both records, but I do see a couple of problems.
1. The syntax for %find is %find(string, view, column). Unless you have a Name view, you skipped a parameter.

2. You use a loop (#FORALL), but never reference the loop variable or change the current db record by any other method. This is why it says the same thing repeatedly.

Recommended fix:
#Alias identify {#IF %find(%1, All, Name) {#FORALL %find( %1, All, Name) {#DBGET %i;say ~[Name: &Name~] ~[Value: &Value~] ~[Bonus: &Bonus~] ~[Weapon: &Weapon~] ~[Required: &Required~]}}}

LightBulb
Senior Member
Reply with quote
titanium
Beginner


Joined: 13 Oct 2001
Posts: 18
Location: USA

PostPosted: Fri Dec 06, 2002 1:07 am   
 
This alias works great!!!, but is there anyway so it would only show the name,value,bonus,weapon,required, etc... if it had it. if an item had all of these fields except, say value. It would only show all of the records except the field value.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Dec 06, 2002 2:07 am   
 
Yes, there's a way. It involves considerable use of the %if function. I don't think it's worth the effort.

LightBulb
Senior Member
Reply with quote
titanium
Beginner


Joined: 13 Oct 2001
Posts: 18
Location: USA

PostPosted: Sun Dec 08, 2002 6:31 am   
 
Well I was going to make the alias look like my identify scrolls...is there any way you can show any example of it only if there was &Name?



Titanium
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Dec 08, 2002 8:54 am   
 
If you want to do it, go ahead. As I said before, I don't think it's worth the effort.

The method is fairly obvious however. Use #IF or %if with each field, and modify your action when the field is empty.

LightBulb
Senior Member
Reply with quote
Sirius
Newbie


Joined: 09 Oct 2002
Posts: 9
Location: USA

PostPosted: Sun Dec 08, 2002 3:55 pm   
 
#IF (&Name=%null) {} {#SHOW Name: &Name}

This is the basic format. Just change it accordlingly.
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