|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Sep 27, 2010 10:23 pm
Grabbing an db item based on the value in 3.x? |
%isvalue help file
According to this we should be able to grab a key with a value using %isvalue, however, this doesn't actually work in practice. I remember awhile back being told that trying to grab the position of something in a db variable was the wrong way to go about it anyways, because of something about a hash system it uses or whatever. So I'm genuinely curious if it's even possible to get the associated key to a value anymore if all you have is the value?
Edit:
aka if you use
Code: |
<class name="isvalue test" id="176">
<var name="test_isvalue" type="Record" id="177">
<value>Name=Zugg|Race=Dwarf|Level=10</value>
<json>{"Level":10,"Race":"Dwarf","Name":"Zugg"}</json>
</var>
</class>
|
#SHOW %item(@test_isvalue, %isvalue(@test_isvalue,"Dwarf"))
You get:
Dwarf
Not:
Race=Dwarf
Edit: Fixed title |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Sep 28, 2010 12:14 am |
Just use the new %dbkey function:
Code: |
#SHOW %dbkey(@test_isvalue, %isvalue(@test_isvalue,"Dwarf")) |
That will show "Race"
There is no way to get the "Race=Dwarf" value anymore since the data is no longer stored like it used to be. You either get "Race" via %dbkey or "Dwarf" via %db or %item. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Tue Sep 28, 2010 12:26 am |
I'd actually prefer just getting race. Thanks Zugg, I wasn't sure if there was a function like that, suppose I should have done a bit more research. :-/
|
|
|
|
|
|