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
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Fri Apr 02, 2004 12:32 am   

Database Questions
 
Does anybody know is there another way to access a sample range of key/value pairs or a single key/value pair from a database variable without knowing the key name, besides using #LOOPDB.

Another question, what is the third field supposed to be, in the %find(,,?) function? Is it a number or the key name? One database uses a number while another uses the field name, it has strange behaviour. Perhaps my database definition was corrupted?

Thanks! Wink
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Apr 02, 2004 4:43 am   
 
Yes, there are other ways to access the values in a database variable. Specifically, you could use %expanddb to alter it to a stringlist which can then be accessed with the list functions.
#ADDK test Name Pega
#ADDK test Rank User
#ADDK test Location Singapore
#ADDK test Posts 260
#SHOW {The third key/value pair of ~@test is: %item( %expanddb( @test, |, /), 3)}

The third field in %find is supposed to be the column name.
Syntax: %find(s[,view,col]))
returns a list of records in a database whose first column contains the string s. If view is specified, it is a string list whose first value is the name of the View to search, and optional second item is the two-character database name. Col is the name of the column to search instead of the first column and is optional. The string list that is returned is a list of record numbers with the database name attached.
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Fri Apr 02, 2004 10:43 am   
 
I didn't notice it before that %expanddb can be used in that way, thanks. Smile

In my current equipment database, the %find() function only works correctly when i supply a number in the 3rd field. In order to find out the correct number to use for each field, I have had to test %find() on sample strings. I have so far confirmed that 4 different numbers represent each of 4 different fields.

While in another database which I rarely use, (in one unconfirmed test some time ago) the column name works in the third field.

It seems as though the database definition stores a hidden value to address each column, and my current database has been corrupted in that area.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Apr 02, 2004 6:10 pm   
 
Heh, I just thought of that particular use yesterday and I haven't seen anyone else suggest it. It's always fun to come up with something new. Smile
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