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


Joined: 18 Dec 2003
Posts: 9

PostPosted: Wed Dec 31, 2003 5:47 am   

Indexing in database variables
 
Hi,

I have a standard database record variable, of the form

name1=value1
name2=value2
...
nameN=valueN

I see the variable as an ordered list of name=value items.

I want to retrieve a name=value pair (or just the key) by using an index. For example, to get the name2 key, I want a function that returns the key given the position. E.g key=%indexdb(@dbvar, 2);

I believe it should be possible to do so since the %iskey function returns a position:

Syntax: %iskey(rec,key)
returns the key number if the key exists in the record

But how do I do it? I could muck with #LOOPDB, but I hope there is a more efficient way of doing that.

Thanks for the help!
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Dec 31, 2003 6:15 am   
 
I can't think of anything off the top of my head to get the key index. Might be an %mss() way of tapping into it.

Usually I have a name=value pair called index with all the unique/odd key names in it.

If your keys have some sort of pattern then you can check from 1 to %numkeys()

You could populate your record variable then capture its keys with %expanddb()
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