|
Anrok Apprentice
Joined: 19 Nov 2010 Posts: 119
|
Posted: 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! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
Anrok Apprentice
Joined: 19 Nov 2010 Posts: 119
|
Posted: Mon Dec 27, 2010 11:20 pm |
That's not good news : ( i guess i'll have to code around this.
Thanks! |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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.
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: 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! |
|
|
|
|
|