|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
Posted: Mon Dec 01, 2008 3:46 am
Ismember question |
is there a way to do a and statement in a ismember?
Code: |
(%ismember( confusion, @afflictions)) and (%ismember( stupidity, @afflictions)) {do this} |
something along those lines? |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Mon Dec 01, 2008 3:52 am |
That's pretty much it, except make sure you preface it with an #IF.
Charneus |
|
|
|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
Posted: Mon Dec 01, 2008 4:04 am |
hrmm. .something is wrong with it though.. the AND is bugging it
this is what I got exactly:
Code: |
#if (%ismember( confusion, @afflictions)) and (%ismember( stupidity, @afflictions)) {do this} |
|
|
|
|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
Posted: Mon Dec 01, 2008 4:09 am |
Figured it out, thanks a ton
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Dec 01, 2008 10:10 pm |
The conditional needs to be completely surrounded by (), which is more of a CMud compatibility thing (unmatched braces will drive you batty in CMud). Regarding each side of the AND equation, inner sets of parentheses are not really needed unless you have a binary operation (ie, a+b).
#if (
%ismember(stuff) and (@a = 12)
) {do this} {else do this} |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
Posted: Tue Dec 02, 2008 2:56 am |
Alright.. need to see how to make this work.
Code: |
#IF ((%ismember( @afflictions, @focuslist)) {focus} |
basically, if any of the @afflictions are in the @focuslist I want it to focus..
Currently it'll only work if there is only one thing in the afflictions. |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Tue Dec 02, 2008 4:06 am |
Ok, thats 2 lists. To do that you'll want to use #FORALL
Code: |
#FORALL @afflictions {#IF (%ismember(%i, @focuslist)) {focus}} |
|
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Dec 02, 2008 9:55 am |
Though you'll probably want to use a variable to detect the first match (the command is focus;matched=1 rather than just focus and the %ismember check also checks the value of @matched).
|
|
|
|
Ralph1971 Wanderer
Joined: 01 Mar 2008 Posts: 64
|
Posted: Thu Dec 04, 2008 4:58 am |
would part of his problem be with his original #if statement be he's missing a closing ")"?
Quote: |
#IF ((%ismember( @afflictions, @focuslist)) {focus}
|
|
|
_________________ Win7-home - Cmud 3.33a
WinXP-pro - Zmud 7.21 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Dec 04, 2008 10:21 am |
That's a good point, actually, I hadn't noticed that. The problem's not that there was one missing at the end, but that there was an extra one at the start. In fact, both of the ones at the end and start aren't needed in this case:
#if %ismember(stuff,stuff) {}
will work just as well. |
|
|
|
|
|