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
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Mon Dec 27, 2010 11:02 pm   

changing dbvar key using a line number?
 
Hey again guys! say i have 3 values in a dbvar called @test={test1=1|test1=2|test1=4} and i want to change any one of them without using their name, can i do it ? I know i can use:
Code:
#loopdb @test {#addkey test %key (%key+1)}


But if i want to make a timer that goes off every second, do i really want to spam my CMUD with #loopdb every second ?

Isnt there an easy way to do this ?
Thanks!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Mon Dec 27, 2010 11:12 pm   
 
I'm not sure how it can differentiate between three keys with the same name.

It is possible to reference a given key=value pair by its position in the list, but it still needs a unique key.

$thisKey=%item(3, @dbvar)
#ADDKEY dbvar {$thisKey=newValue}
_________________
Discord: Shalimarwildcat
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Mon Dec 27, 2010 11:20 pm   
 
That's not good news : ( i guess i'll have to code around this.
Thanks!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Dec 28, 2010 2:20 am   
 
You can actually do it, with difficulty, with %addkey(). You'd have to refer to the position in the list, though.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Dec 28, 2010 7:23 pm   
 
Why do you have 3 keys of the same name? It goes against one of the major design prinicipals of db variables.

If you need to have several different values associated with one key name, might I suggest storing a string list of values under the single key in the db variable.
_________________
Asati di tempari!
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