// Borland C++ Builder
// Copyright (c) 1995, 1999 by Borland International
// All rights reserved

// (DO NOT EDIT: machine generated header) 'AdvPars.pas' rev: 4.00

#ifndef AdvParsHPP
#define AdvParsHPP

#pragma delphiheader begin
#pragma option push -w-
#include <AdvGrid.hpp>	// Pascal unit
#include <Windows.hpp>	// Pascal unit
#include <Grids.hpp>	// Pascal unit
#include <SysUtils.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <SysInit.hpp>	// Pascal unit
#include <System.hpp>	// Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Advpars
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TokenType { Delimiter, Non, variable, Digit, endExpr, Error, Func };
#pragma option pop

struct TokenRec;
typedef TokenRec *TokenPtr;

#pragma pack(push, 4)
struct TokenRec
{
	TokenRec *Next;
	short Start;
	short Close;
} ;
#pragma pack(pop)

typedef void __fastcall (__closure *TIsCustomFunction)(System::TObject* sender, AnsiString &func, bool 
	&match);

typedef void __fastcall (__closure *TCalcCustomFunction)(System::TObject* sender, AnsiString &func, 
	double &param);

class DELPHICLASS TGridFormula;
#pragma pack(push, 4)
class PASCALIMPLEMENTATION TGridFormula : public System::TObject 
{
	typedef System::TObject inherited;
	
private:
	int i;
	int varlen;
	AnsiString fExpression;
	int fCol;
	int fRow;
	int fErrorPosition;
	Grids::TStringGrid* fStringGrid;
	Classes::TStringList* fCellNameList;
	TIsCustomFunction fIsCustomFunction;
	TCalcCustomFunction fCalcCustomFunction;
	bool fUseRCNames;
	AnsiString __fastcall ReadWord();
	double __fastcall ReadNumber(void);
	void __fastcall SkipBlanks(void);
	TokenType __fastcall GetToken(void);
	bool __fastcall MatchFunc(AnsiString Match, double &Res, TokenType &n);
	bool __fastcall MatchDualParamFunc(AnsiString Match, double &Res1, double &Res2, TokenType &n);
	bool __fastcall MatchTriParamFunc(AnsiString Match, double &Res1, double &Res2, double &Res3, TokenType 
		&n);
	bool __fastcall MatchToken(AnsiString Match);
	bool __fastcall doPI(double &r);
	bool __fastcall doE(double &r);
	bool __fastcall doCol(double &r);
	bool __fastcall doRow(double &r);
	bool __fastcall DoNow(double &r);
	bool __fastcall DoToday(double &r);
	bool __fastcall DoChoose(double &Res, TokenType &n);
	bool __fastcall DoLt(double &Res, TokenType &n);
	bool __fastcall DoSt(double &Res, TokenType &n);
	bool __fastcall DoEq(double &Res, TokenType &n);
	bool __fastcall DoFrac(double &Res, TokenType &n);
	bool __fastcall DoFact(double &Res, TokenType &n);
	bool __fastcall DoInt(double &Res, TokenType &n);
	bool __fastcall DoChs(double &Res, TokenType &n);
	bool __fastcall DoSin(double &Res, TokenType &n);
	bool __fastcall DoCos(double &Res, TokenType &n);
	bool __fastcall DoTan(double &res, TokenType &n);
	bool __fastcall DoCoTan(double &res, TokenType &n);
	bool __fastcall DoSinh(double &Res, TokenType &n);
	bool __fastcall DoCosh(double &Res, TokenType &n);
	bool __fastcall DoTanh(double &res, TokenType &n);
	bool __fastcall DoCoTanh(double &res, TokenType &n);
	bool __fastcall DoMonth(double &res, TokenType &n);
	bool __fastcall DoYear(double &res, TokenType &n);
	bool __fastcall DoDay(double &res, TokenType &n);
	bool __fastcall DoDayOfWeek(double &res, TokenType &n);
	bool __fastcall DoMinute(double &res, TokenType &n);
	bool __fastcall DoSecond(double &res, TokenType &n);
	bool __fastcall DoHour(double &res, TokenType &n);
	bool __fastcall DoExp(double &Res, TokenType &n);
	bool __fastcall DoLn(double &res, TokenType &n);
	bool __fastcall DoLog10(double &res, TokenType &n);
	bool __fastcall DoLog2(double &res, TokenType &n);
	bool __fastcall DoAbs(double &res, TokenType &n);
	bool __fastcall DoArcTan(double &res, TokenType &n);
	bool __fastcall DoArcCoTan(double &res, TokenType &n);
	bool __fastcall DoRound(double &res, TokenType &n);
	bool __fastcall DoTrunc(double &res, TokenType &n);
	bool __fastcall DoDegrees(double &res, TokenType &n);
	bool __fastcall DoRadians(double &res, TokenType &n);
	bool __fastcall DoRand(double &res, TokenType &n);
	bool __fastcall DoSqr(double &res, TokenType &n);
	bool __fastcall DoCube(double &res, TokenType &n);
	bool __fastcall DoSqrt(double &res, TokenType &n);
	bool __fastcall DoArcSin(double &res, TokenType &n);
	bool __fastcall DoArcCos(double &res, TokenType &n);
	void __fastcall DoFunc(double &res, TokenType &n);
	void __fastcall Primitive(double &res, TokenType &n);
	double __fastcall Sign(double Number);
	void __fastcall Level6(double &res, TokenType &n);
	void __fastcall Level5(double &res, TokenType &n);
	void __fastcall Level4(double &res, TokenType &n);
	void __fastcall Level3(double &res, TokenType &n);
	void __fastcall Level2(double &res, TokenType &n);
	void __fastcall Level1(double &res, TokenType &n);
	double __fastcall GetExpr(bool &Valid);
	void __fastcall DoErr(TokenType &n);
	void __fastcall GetNextVar(AnsiString &full, AnsiString &expr, AnsiString &c, AnsiString &r);
	bool __fastcall IsCellVar(void);
	double __fastcall GetCellVar(void);
	double __fastcall GetCellVal(int col, int row);
	int __fastcall IsCellRangeFunc(AnsiString match);
	int __fastcall IsCellNameRef(AnsiString match);
	bool __fastcall SolveCellRangeFunc(const AnsiString match, double &res, int func);
	bool __fastcall SolveCellNameRef(AnsiString match, double &res);
	Windows::TPoint __fastcall GetCoord(AnsiString rng);
	
public:
	__fastcall TGridFormula(Grids::TStringGrid* grid);
	__fastcall virtual ~TGridFormula(void);
	__property AnsiString Expression = {read=fExpression, write=fExpression};
	__property int Row = {read=fRow, write=fRow, nodefault};
	__property int Col = {read=fCol, write=fCol, nodefault};
	__property int ErrorPosition = {read=fErrorPosition, write=fErrorPosition, nodefault};
	bool __fastcall Calc(double &r);
	__property Classes::TStringList* CellNameList = {read=fCellNameList};
	__property bool UseRCNames = {read=fUseRCNames, write=fUseRCNames, nodefault};
	
__published:
	__property TIsCustomFunction IsCustomFunction = {read=fIsCustomFunction, write=fIsCustomFunction};
	__property TCalcCustomFunction CalcCustomFunction = {read=fCalcCustomFunction, write=fCalcCustomFunction
		};
};

#pragma pack(pop)

//-- var, const, procedure ---------------------------------------------------
extern PACKAGE int __fastcall VarPos(AnsiString su, AnsiString s, int &vp);

}	/* namespace Advpars */
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Advpars;
#endif
#pragma option pop	// -w-

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// AdvPars
