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
Lasivian
Wanderer


Joined: 25 Jan 2002
Posts: 76
Location: USA

PostPosted: 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
Reply with quote
Erasmus
Wanderer


Joined: 04 Aug 2004
Posts: 82
Location: Philadelphia

PostPosted: 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
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: 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
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