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
priit
Beginner


Joined: 03 Feb 2004
Posts: 29
Location: Estonia

PostPosted: Wed Jun 16, 2004 11:55 am   

retrieving the string number out of the string lst
 
is there possible to find the number of string in the string list?

example string list:

#VAR whatever {A dove rests near one of the flowers|A blue dragonfly is circling around|A nightingale is here, chirping a sweet melody|A finch flies low above the ground}

but
#SHOW %pos('A finch flies low above the ground',@whatever)
gives me 121 instead of 4 I was hoping for... what command or function should I use instead?
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Wed Jun 16, 2004 2:52 pm   
 
What you want to use is %ismember.

quote:

#VAR whatever {A dove rests near one of the flowers|A blue dragonfly is circling around|A nightingale is here, chirping a sweet melody|A finch flies low above the ground}
#SHOW %pos('A finch flies low above the ground',@whatever)


Will display "1" because it is the first member of the list. The opposite function is %item(@whatever,1), which will display the first member of the string.

%pos is used to locate a character, or string of characters, within a string, regardless of if it's a list or not.

For more details working with string lists, open the Help docs, go to Contents, expand References, expand Function List, expand Lists.

If you have something in particular you're trying to accomplish, giving the details will help us help you better.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Wed Jun 16, 2004 5:38 pm   
 
ismember

Syntax: %ismember(s,list)

return 0 (false), if s is not a member of the given string list. Otherwise return the item number (position of s in the list)
Examples:

#SHOW %ismember("abc","def|ghi jk|abc")

Displays 3

#VAR friendsList {Zugg|Darker|Penny}
#VAR petitioner zyxcef
#IF (%ismember(@petitioner,@friendsList)) {cast heal @petitioner} {say Nope.}

sends 'say Nope.' to the mud.



#SHOW %ismember("A finch flies low above the ground", @whatever)
Reply with quote
priit
Beginner


Joined: 03 Feb 2004
Posts: 29
Location: Estonia

PostPosted: Thu Jun 17, 2004 9:13 am   
 
thanks got my script working...

problem were, that using %ismember function didnt seem logical - always thought it returns 1 or true when it is memeber and 0 or false when not. never really thought it could have some added functionality, so never bothered even reading the help about it [:I]
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