|
shaun.murray Magician
Joined: 23 Jul 2005 Posts: 334 Location: Chicago
|
Posted: Thu Jul 27, 2006 1:33 pm
#IF question right quick |
Would this be possible?
Code: |
#alias {test} {#if (%1 <> "one"|"two"|"three") {#showme Please enter either -one, two, or three-. Thank you.};#if (%1 = "one"|"two"|"three") {#showme Ding!!}} |
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Thu Jul 27, 2006 2:29 pm |
I've been trying different variations on this and couldn't get them to work, so I'm missing something. The main thing is that you don't need two if statements since they are a true-false of each other as it is and it is shorter and easier to do #IF (condition) {actions if condition true} {actions if condition false}. The issue seems to be either in the condition operator, the use of quotation marks, or the OR operator.
Yup...it was the use of the OR operator. The way you have is it not programatically the same as saying "If the number is this or this or that". Computer need it more like "If the number is this, or the number is that, or the number is that."
Also, don't know why you are using #SHOWME. You just trying to use #SHOW there?
anyhow #if ( %1 = "one" | %1 = "two" | %1 = "three") {#show Ding!!} {#show Please enter either -one, two, or three-. Thank you.} should work |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Thu Jul 27, 2006 2:39 pm |
#ALIAS test {#if (%ismember( %1, {one|two|three}) = 0) {#say Please enter either -one, two, or three-. Thank you.} {#say Ding!!}}
You don't need to do the #if twice, since a normal if statement is
#if (test) {then} {else}
Edit: Darn, was beaten to it ;) |
|
|
|
shaun.murray Magician
Joined: 23 Jul 2005 Posts: 334 Location: Chicago
|
Posted: Thu Jul 27, 2006 2:46 pm |
Yeah, the SHOWME was meant as SHOW, just using it as an example. How about this?
Code: |
#var numbers {one|two|three|four|five|six|seven|eight|nine|ten}
#alias test {#if (%ismember( %1, @numbers) = 0) {#say Please enter a number 1 thru 10} {#say Ding!!}} |
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Thu Jul 27, 2006 5:21 pm |
I completely forgot about %ismember.
That should work shaun.murray |
|
|
|
shaun.murray Magician
Joined: 23 Jul 2005 Posts: 334 Location: Chicago
|
Posted: Thu Jul 27, 2006 6:38 pm |
Hhmmmmmm.... Well, cool! I think that configuring a variable and letting the alias to the check on the variable might be the best way to go! Thanks for everyone's help!!!!! *cheers*
|
|
|
|
|
|