/**************************************************************************
 *                                                                        *
 *                                                                        *
 *          This code is copyright (c) 1992                               *
 *                     Athena Design, Inc.                                *
 *                     and David Pollak                                   *
 *                                                                        *
 *                ALL RIGHTS RESERVED                                     *
 *                                                                        *
 *                                                                        *
 *                                                                        *
 *                                                                        *
 *                                                                        *
 **************************************************************************/

#import "dec.h"
#import <libc.h>

@implementation DecAddIn

+ (char *)name
{
	return "DEC";
	}
	
- execute:(void *)stack numberOfParams:(int)num sheet:(void *)sh
{
	AddInValue aiv;
	double n = 0;
	int error = noError;
	
	initAddInValue(&aiv);
	
	if (num != 1) pushErrorOnStack(stack,badFormulaError);
	else {
		popValueFromStack(stack,&aiv);
		n = getAddInValueNumber(&aiv,&error);
		if (error != noError) pushErrorOnStack(stack,error);
		else pushNumberOnStack(stack,n - 1);
		}
	
	freeAddInValue(&aiv);
	return self;
	}

@end
