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
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Tue Feb 07, 2006 3:41 pm   

Simple data record question/request
 
Is there an easier way to get items from a data record by position other than to use %expanddb and convert it to a string list? Basically, I don't know (nor care) what the keys are ahead of time, and I just want to display the first 5-10 keys in a status window. If I use a string list, I can use %item to grab the elements. I'd prefer to have something simple to do a similar thing with a data record because it's going to be updated in real time and could be fast changing. Too complex a function would really slow down my display, even though the data records themselves are very fast otherwise. Thanks in advance for any ideas anyone might have on this.
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Tue Feb 07, 2006 4:57 pm   
 
Keep the first key of the db record as a list of keys.
#ADDITEM MyRecord.keys Test
#ADDKEY MyRecord Test Value1
etc

Then just show %db(@MyRecord,%item(@MyRecord.keys,1))

untested but I always use an index like that. Also useful to check to see if a record has a key to update, delete or do something.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Tue Feb 07, 2006 5:59 pm   
 
Brilliant answer! I shouldn't have to worry about the index becoming one of the keys that get displayed, either, because I control which ones are added... I like it. Thanks!
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