|
Mizui Newbie
Joined: 05 May 2010 Posts: 6
|
Posted: Wed May 26, 2010 4:48 am
Switch Cmd Bug? |
I am not sure if something is wrong with the switch function or if I did something wrong
This is part of my code, i think the code is pretty much self explainatory:
Code:
#sh %eval($aCon != $bCon);
#switch {$aCon != $bCon} {#sh case 1;$case = 1}
{$aCon = $bCon && $c == $d} {#sh case 2;$case = 2}
{$aCon = $bCon && $c > $d} {#sh case 3;$case = 3}
{$aCon = $bCon && $c < $d} {#sh case 4;$case = 4}
{#sh {%ansi(high,red)Fail at Switch Case!}};
The output:
> 0
case 1
If %eval($aCon != $bCon) shows 0,
output shouldn't show case 1.
Wondering if this is a bug that I should report or I am just stupid and overlook something. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed May 26, 2010 4:58 am |
{} no longer works as () in CMud.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed May 26, 2010 5:47 am |
To elaborate, the correct syntax is:
#SWITCH (expression) {commands} (expression2) {commands2}
It's the same with #IF statements:
#IF (expression) {true} {false}
not
#IF {expression} {true} {false}
Charneus |
|
|
|
|
|