Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
fuktfursten
Beginner


Joined: 17 Apr 2007
Posts: 20

PostPosted: Thu Apr 19, 2007 2:11 pm   

[1.28] %switch
 
Cannot seem to figure out how to use this function properly.. or its bugged? Using it within a variable like so:

---

Var name: test
content:

%switch($arg1 < 0.125, "RED", $arg1 < 0.25, "BROWN", $arg1 < 0.5, "YELLOW", $arg1 < 1.0, "CYAN", 1, "BOLD,CYAN")

Param: $arg1

---

#SHOW @test(0.124) gives me RED
#SHOW @test(0.249) gives me BROWN
#SHOW @test(0.499) gives me YELLOW
#SHOW @test(0.999) gives me YELLOW(!?)
#SHOW @test(1.24) gives me YELLOW(!?)

Don't remember the exact syntax on how I did this (triggers at home). But everything seem to work up until < 0.5
What am I doing wrong? or is this bugged?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Apr 19, 2007 3:26 pm   
 
It's not working for me either. Looks like a bug.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Apr 19, 2007 5:16 pm   
 
Yep, looks like a bug. It's not parsing stuff correctly after the 3rd argument. Added to bug list.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Apr 19, 2007 5:29 pm   
 
Ditto. Also in my testing I came across something else that may be a bug as well.

Code:
%switch( ($arg1 < 0.125), "RED", ($arg1 < 0.25), "BROWN", ($arg1 < 0.50), "YELLOW", ($arg1 < 1.00), "CYAN", ($arg1 >= 1.0), "BOLD,CYAN")


You get a syntax error at the equal sign, and I don't think you should. Oddly enough, the following doesn't.

Code:
%switch ($arg1 < 0.5, "Yay!, man", $arg1 >= 1.5, "Boo, man")
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Apr 20, 2007 5:36 pm   
 
As I mentioned, it doesn't parse anything after the 3rd argument correctly. In your first example, the >= was in the 9th argument, and in your second example it was in the 3rd argument. Nothing past the 3rd argument will work (the parser doesn't get put into "expression" mode, so it doesn't know that >= is an expression operator).
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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