Fixed the switch() function bug...

...which made this function always return second argument instead of
proper result
This commit is contained in:
Bartek Waresiak 2008-03-25 16:31:18 +00:00
parent 7cd29ccaf8
commit 01d1d4179c

View file

@ -66,13 +66,13 @@ private:
class switch_function : public function_expression {
public:
explicit switch_function(const args_list& args)
: function_expression("switch", args, 4, -1)
: function_expression("switch", args, 3, -1)
{}
private:
variant execute(const formula_callable& variables) const {
variant var = args()[0]->evaluate(variables);
for(int n = 0; n < args().size()-1; n += 2) {
for(int n = 1; n < args().size()-1; n += 2) {
variant val = args()[n]->evaluate(variables);
if(val == var) {
return args()[n+1]->evaluate(variables);