|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Wed Oct 19, 2005 9:51 pm
Easy %case Q |
I want the %case to work like the #case command
Quote: |
#CASE @joincmd {join} {rescue}
if the variable @joincmd is 1 (or 3,5,7...) the string join is returned, otherwise the string rescue is returned. |
Thus i want to:
%case(@variable_containing_a_number, "if it is a odd return this", "if it is not odd return this")
But like that it wont work. |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient.
Last edited by BlackSmith on Thu Oct 20, 2005 8:35 pm; edited 1 time in total |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Oct 20, 2005 1:16 am |
%if(%mod(@variable,2),"odd","even")
%case(%eval(%mod(@variable,2)+1),"odd","even")
I like the %if version better. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Thu Oct 20, 2005 12:49 pm |
So the case function cant hack it in anyform by itself?
blah.
gota do it with the if thingy then. |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Oct 20, 2005 7:45 pm |
Actually the behaviour of #CASE where it repeats is a bug. No one ever reports it because those that have found it, like you, thought it was useful. Still, it is counter to the specification of #CASE.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Oct 20, 2005 7:49 pm |
Really? The earliest helpfiles I've seen (early version 6) made it seem like that was an intentional feature.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Thu Oct 20, 2005 8:25 pm |
As a matter of fact i was looking at the current documentation today for another problem and they also made it seem like the wrapping was intentional. Of course, it could just be Zugg doing a bit of that age old software joke. "It's not a bug, it's a feature!"
|
|
_________________ Asati di tempari! |
|
|
|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Thu Oct 20, 2005 8:31 pm |
Vijilante wrote: |
Actually the behaviour of #CASE where it repeats is a bug. |
Help wrote: |
CASE
Syntax: #CA index command1 [commandn]
Allows you to select a command from a list to be executed. The index parameter determines the command to execute from the list given by command1..commandn. If index is greater then the number of commands, it wraps around. For example, if there are four commands and you ask for the fifth, the first is returned. This allows you to use the predefined variable %random to select a random command.
If the index is negative, results are undefined.
CASE examples
#CASE 2 {first command} {second command} {third command}
sends the string second command to the MUD
#CASE @joincmd {join} {rescue}
if the variable @joincmd is 1 (or 3,5,7...) the string join is returned, otherwise the string rescue is returned.
#CASE %random {Hello} {Hi there} {Hiya} {Hi}
returns a random string from the given list to the MUD. |
To me it looks quite how it should work, only that the function does not work right. |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient. |
|
|
|
|
|