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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Bluebear
Beginner


Joined: 10 Oct 2007
Posts: 17

PostPosted: Sat Jan 05, 2008 3:28 pm   

Database Question
 
Hi all,

I am attempting to use the database for the first time in CMUD, (I never used it in ZMUD either).

I am trying to record the number of individiual herbs in my pouches.

So I have created a database with two fields herbname and herbnumber. I have a script that clears the records, then another that captures the herb quantities in each pouch and adds them up.

The problem is that the record numbers for the herbs is changed all the time when I start a session.

I therefore need to be able to call a record using the herb name ie the value of the field called herbname. Looking through the helpfiles, it appears the only way to call a record is with is with is database generated number (which varies for each herb every day!)

Any thoughts please?

Thank you.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Jan 05, 2008 5:11 pm   
 
Really, if your database would only have two entries, use a data record variable instead. The keys can be the herb names and the values can be the numbers of herbs. Much easier.

Herbs.someherb = 383
Herbs.someotherherb = 267
#add Herb.someherb -1
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Bluebear
Beginner


Joined: 10 Oct 2007
Posts: 17

PostPosted: Sat Jan 05, 2008 5:35 pm   
 
Thanks for the help.

I have been using individual variables to store the herb numbers in up until now (about 60 different variables).

Will a data record variable happily store 60 entries?

Also, just out of interest, will the single large data variable use less computer resources than the 60 seperate ones? Thanks
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Jan 05, 2008 10:03 pm   
 
Yes, and I'm not sure ;)

I'm currently using a data record variable with 72 entries. So 60 even should be no problem.
As for resources, I would GUESS Yes, but without seeing the code or tediously testing it I can't know for sure. But it SHOULD.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Jan 05, 2008 11:11 pm   
 
What do you mean by "resources"? Accessing a data record variable is slower than accessing a normal variable, but not so's you'd notice. The hash table might mean it takes up slightly more memory, but on a scale of bytes so, again, it doesn't really matter.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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