// $Id: xxl_if.cc,v 1.4 1997/01/07 00:48:08 aml Exp $

#include "xxl_funcs.hh"
#include "sheet.hh"


Stack_elem *If::eval(Stack_elem *p,Sheet *sheet, short col, short row) {
    double x;

    if (!sheet->propagate_error(p,se)) {
        if (cnt == 0) {
            x = sheet->stack_value(p);
            if (x != 0) 
                choice = 1;
            else 
                choice = 2;
        }
        
        if ((cnt >= 1) && cnt == choice) 
            *se = *p;
    }

    cnt++;
    return(se);
}

If::If() {
  cnt = 0;
  choice = 0;
  se = new Stack_elem();
}

If::~If() {
  delete se;
}

// $Log: xxl_if.cc,v $
// Revision 1.4  1997/01/07  00:48:08  aml
// Error propagation.
//
// Revision 1.3  1996/11/28  15:45:30  aml
// *** empty log message ***
//
// Revision 1.2  1996/03/08 19:00:21  aml
// Fixed problem in string_single_arg macro
// Created if function, boolean evaluations and so on.
//
// Revision 1.1  1996/03/08 12:50:50  aml
// Initial revision
//
