|
Lasivian Wanderer
Joined: 25 Jan 2002 Posts: 76 Location: USA
|
Posted: Tue Apr 20, 2010 7:15 pm
How do I get the location of a data record value if I match the key? |
I've got a data record called @botspelltriggers showing oh=Heal|or=Regenerate|om=Mortal Restore|ohg=Hand of God
Now the code:
@tempbotspellword = or
tempspellloc = %iskey(@botspelltriggers,@tempbotspellword)
returns "2" correctly as @tempspellloc, but how do I then tell the script to use the corresponding value?
Logically something like @botspelltriggers.tempspellloc would work but it doesn't.
Thanks |
|
|
|
Erasmus Wanderer
Joined: 04 Aug 2004 Posts: 82 Location: Philadelphia
|
Posted: Tue Apr 20, 2010 7:22 pm |
%db(@botspelltriggers,@tempbotspellword)
Quote: |
Logically something like @botspelltriggers.tempspellloc would work but it doesn't. |
As a side note, this would be applicable to a string list, but not a database variable. Theoretically, the position of the key in a db variable is irrelevant since the point is to reference the key. |
|
_________________ Erasmus |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Apr 20, 2010 7:42 pm |
The %iskey() function will return the position of the key, just like %ismember() returns the position of the element in the stringlist. To reference the value, use either the @var.key notation (which doesn't work when key is a variable) or the %db() function.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
|
|