/*
Auto:		smake MCalc
*/


/* $Revision Header built automatically *************** (do not edit) ************
**
** © Copyright by GuntherSoft
**
** File             : SnakeSYS:CPrgs/MUICalc/MCalc.h
** Created on       : Saturday, 02.10.93 02:16:34
** Created by       : Kai Iske
** Current revision : V1.7
**
**
** Purpose
** -------
**   - Header-File for MCalc
**
** Revision V1.7
** --------------
** created on Mittwoch, 15.02.95 13:52:27  by  Kai Iske.   LogMessage :
**  -*-  changed on Donnerstag, 07.12.95 00:03:07  by  Kai Iske.   LogMessage :
**   - Recompilded using SAS-C 6.56 and MUI 3.0 header
**  -*-  created on Mittwoch, 15.02.95 13:52:27  by  Kai Iske.   LogMessage :
**   - MCalc didn`t calc the (n over k) function correctly. It used
**     to calculate n!/(n-k)!, not n!/(k! * (n-k)!)
**     (Reported by :Andreas Gabold)
**
** Revision V1.6
** --------------
** created on Freitag, 27.01.95 15:59:41  by  Kai Iske.   LogMessage :
**  -*-  changed on Freitag, 27.01.95 16:33:37  by  Kai Iske.   LogMessage :
**   - Archive didn`t contain Protos.h header file
**     (Reported by : Kay-Uwe Drankmeister)
**  -*-  changed on Freitag, 27.01.95 16:32:58  by  Kai Iske.   LogMessage :
**   - Function group was vertically sizable. Changed
**     (Reported by : Kay-Uwe Drankmeister)
**  -*-  changed on Freitag, 27.01.95 16:22:02  by  Kai Iske.   LogMessage :
**   - Within the Prefs window, some entries positions in the cycle
**     chain were mixed up.
**     (Reported by : Kay-Uwe Drankmeister)
**  -*-  changed on Freitag, 27.01.95 16:19:00  by  Kai Iske.   LogMessage :
**   - RegisterGroup wasn`t contained in CycleChain
**     (Reported by : Kay-Uwe Drankmeister)
**  -*-  changed on Freitag, 27.01.95 16:18:00  by  Kai Iske.   LogMessage :
**   - LinReg, StdDev, and Constants windows won`t have menus
**     anymore, sorry ;)
**  -*-  changed on Freitag, 27.01.95 16:04:15  by  Kai Iske.   LogMessage :
**   - Std.Deviation, Lin.Regression and Constants window didn`t
**     have a cycle-chain set.
**     (Reported by : Kay-Uwe Drankmeister)
**  -*-  created on Freitag, 27.01.95 15:59:41  by  Kai Iske.   LogMessage :
**   - Changed items within "Windows" menu, to toggle menus
**
** Revision V1.5
** --------------
** created on Donnerstag, 25.08.94 03:09:39  by  Kai Iske.   LogMessage :
**  -*-  changed on Saturday, 21.01.95 17:43:49  by  --- Unknown ---.   LogMessage :
**   - Added new function to menu/ARexx. DELETEHISTORY will delete
**     an entry from the history list.
**     (Requested by : Sorry, I lost you name, but thanks for the
**     suggestions and the translation of the manual)
**  -*-  changed on Samstag, 21.01.95 17:15:17  by  Kai Iske.   LogMessage :
**   - Added support for GRADS
**     (Requested by : Sorry, I lost you name, but thanks for the
**     suggestions and the translation of the manual)
**  -*-  changed on Samstag, 21.01.95 16:07:13  by  Kai Iske.   LogMessage :
**   - Introduced exg operator, which exchanges the contents
**     of two memories
**     (Requested by : Sorry, I lost you name, but thanks for the
**     suggestions and the translation of the manual)
**  -*-  changed on Samstag, 21.01.95 01:06:35  by  Kai Iske.   LogMessage :
**   - Added great support for physical constants. 31 listed
**     (Requested by : Sorry, I lost you name, but thanks for the
**     suggestions and the translation of the manual)
**  -*-  changed on Freitag, 20.01.95 18:37:04  by  Kai Iske.   LogMessage :
**   - Added full features linear regression support
**     (Requested by : Volker Güth)
**  -*-  changed on Freitag, 20.01.95 12:58:05  by  Kai Iske.   LogMessage :
**   - Added standard deviation support
**     (Requested by : Volker Güth)
**  -*-  changed on Freitag, 20.01.95 12:26:16  by  Kai Iske.   LogMessage :
**   - Added (n k) n-over-k function, 1/x, and the y-th root of x
**     function.
**     (Requested by : Sorry, I lost you name, but thanks for the
**     suggestions and the translation of the manual)
**  -*-  changed on Donnerstag, 19.01.95 17:51:12  by  Kai Iske.   LogMessage :
**   - Increased number of internal memories from 3 to 18 (I-Z)
**  -*-  changed on Donnerstag, 19.01.95 17:25:41  by  Kai Iske.   LogMessage :
**   - Changed function group to use Registers/Cycle Gadget,
**     according to your MUI settings.
**   - MCalc requested any muimaster.library, even though version
**     7 (MUI 2.x) was required
**  -*-  changed on Mittwoch, 18.01.95 19:58:42  by  Kai Iske.   LogMessage :
**   - Some of the input gadgets didn`t react on key nor mouse
**     activations.
**     (Reported by : Andreas Kirchwitz, and several others)
**  -*-  changed on Freitag, 26.08.94 14:22:31  by  Kai Iske.   LogMessage :
**   - Recompiled scanner using Flex 2.4.7
**  -*-  created on Donnerstag, 25.08.94 03:09:39  by  Kai Iske.   LogMessage :
**   - The format identifier for binary values has been changed;
**     I forgot to change the output format identifier as well.
**
** Revision V1.4
** --------------
** created on Thursday, 17.03.94 20:09:05  by  Kai Iske.   LogMessage :
**  -*-  changed on Donnerstag, 18.08.94 17:35:24  by  Kai Iske.   LogMessage :
**   - MCalc didn`t even care about Percent calculations
**  -*-  changed on Sonntag, 07.08.94 20:30:27  by  Kai Iske.   LogMessage :
**   - atan() wasn`t definied for some ranges (somehow)
**  -*-  changed on Sonntag, 07.08.94 20:17:13  by  Kai Iske.   LogMessage :
**   - The InputString will be default object now
**  -*-  created on Thursday, 17.03.94 20:09:05  by  Kai Iske.   LogMessage :
**   - Recompiled with Scanner generated by flex 2.4.6
**
** Revision V1.3
** --------------
** created on Friday, 11.02.94 23:34:08  by  Kai Iske.   LogMessage :
**  -*-  changed on Friday, 11.02.94 23:35:32  by  Kai Iske.   LogMessage :
**   - One couldn`t use 1e3 for scientific notation of 1000. You
**     had to write 1.0e3. Changed
**     (Reported by : Henry Norman)
**   - No more error lines will be copied from History
**     (Requested by : Stefan Stuntz)
**  -*-  created on Friday, 11.02.94 23:34:08  by  Kai Iske.   LogMessage :
**   - "Radiant" was wrong. Changed. Why didn`t anybody tell me.
**     (Reported by : Henry Norman)
**   - Chose wrong case for mathematical "e".
**     (Reported by : Henry Norman)
**
** Revision V1.2
** --------------
** created on Tuesday, 19.10.93 23:41:00  by  Kai Iske.   LogMessage :
**  -*-  changed on Wednesday, 08.12.93 23:48:31  by  Kai Iske.   LogMessage :
**   - Default number of history lines increased
**     (Requested by : Stefan Stuntz)
**  -*-  changed on Sunday, 05.12.93 22:30:41  by  Kai Iske.   LogMessage :
**   - No checks were made on the ENTRY argument to an ARexx
**     function
**  -*-  changed on Sunday, 05.12.93 18:13:56  by  Kai Iske.   LogMessage :
**   - For calculations via ARexx one can set the type, size, sign
**     and angle flags seperately, now
**  -*-  changed on Sunday, 05.12.93 17:50:09  by  Kai Iske.   LogMessage :
**   - Improved error handling from within ARexx commands a bit
**  -*-  changed on Sunday, 05.12.93 17:46:35  by  Kai Iske.   LogMessage :
**   - MUIProCalc may output TeX style mathematical expressions
**     when using the ARexx commands. Additionally there is another
**     option to convert expressions to TeX format.
**     (Requested by : Volker Güth)
**  -*-  changed on Sunday, 05.12.93 16:47:59  by  Kai Iske.   LogMessage :
**   - Added more ARexx functions to the default ones
**     (CALC, GETINPUT, GETOUTPUT)
**     (Requested by : Volker Güth)
**  -*-  changed on Sunday, 05.12.93 01:47:36  by  Kai Iske.   LogMessage :
**   - MUIProCalc didn`t handle extremly small values
**     (Reported by : Volker Güth)
**  -*-  changed on Sunday, 05.12.93 01:38:18  by  Kai Iske.   LogMessage :
**   - Default values weren`t set up
**   - ACLR and CLR gadget have got menu entries too, now
**     (Requested by : Volker Güth)
**   - History entries may be copied to clipboard now
**     (Requested by : Volker Güth)
**  -*-  changed on Saturday, 27.11.93 01:01:25  by  Kai Iske.   LogMessage :
**   - Recompiled using SAS 6.50
**  -*-  changed on Wednesday, 20.10.93 00:24:41  by  Kai Iske.   LogMessage :
**   - Bug in ListView display fixed
**  -*-  created on Tuesday, 19.10.93 23:41:00  by  Kai Iske.   LogMessage :
**   - You may now tell MCalc to clear the input string after
**     hitting RETURN or EXEC.
**
** Revision V1.1
** --------------
** created on Tuesday, 12.10.93 01:50:26  by  Kai Iske.   LogMessage :
**  -*-  changed on Sunday, 17.10.93 15:03:10  by  Kai Iske.   LogMessage :
**   - Save and Use gadgets weren`t arranged as proposed
**     by the AUISG. (Reported by: Stefan Stuntz)
**   - Changed layout of Prefs window a bit
**     (Suggested by: Stefan Stuntz)
**  -*-  changed on Friday, 15.10.93 18:39:50  by  Kai Iske.   LogMessage :
**   - NOT operator didn`t behave as expected ;) It was a simple
**     negate... (Reported by : Top on IRC)
**  -*-  changed on Thursday, 14.10.93 18:01:32  by  Kai Iske.   LogMessage :
**   - Hex-Values may be entered using 'C'-Style now (e.g. 0xff)
**  -*-  changed on Thursday, 14.10.93 00:34:55  by  Kai Iske.   LogMessage :
**   - One can use the faktorian '!' behind numbers now, too.
**     (Suggested by : Top on IRC)
**  -*-  changed on Thursday, 14.10.93 00:28:52  by  Kai Iske.   LogMessage :
**   - One could accidentially change the ordering of the
**     functions and input-gadgets groups by using
**     'No Functions' and 'No Input' (reported by: Top on IRC)
**  -*-  created on Tuesday, 12.10.93 01:50:26  by  Kai Iske.   LogMessage :
**   - Order of Input and Ouput gadgets (String + ListView) may be
**     set now, ie. the input string may show up underneith the
**     ListView and vice versa (Requested by Dirk Federlein)
**
** Revision V1.0
** --------------
** created on Saturday, 02.10.93 02:16:34  by  Kai Iske.   LogMessage :
**     --- Initial release ---
**
*********************************************************************************/
#define REVISION "1.7"
#define REVDATE  "07.12.95"
#define REVTIME  "00:03:07"
#define AUTHOR   "Kai Iske"
#define VERNUM   1
#define REVNUM   7


#ifndef		MCALC_H
#define		MCALC_H



/**********************************************************************/
/*                         Parser-Prototypes                          */
/**********************************************************************/
int		yyparse(void);
int		yyerror(char *s);
ULONG		make_ulong(double OldVal);
double		calc_fak(double Fak);
double		calc_angle(double Value);
BOOL		check_angle(double Value, int Mode);
BOOL		add_standard_value(double Value);
BOOL		add_linear_value(double ValueX, double ValueY);
int		numbers_in_list(struct List *Lst);
double		calc_average(struct List *Lst, BOOL LinearValueY);
double		calc_population(struct List *Lst, BOOL LinearValueY);
double		calc_sample(struct List *Lst, BOOL LinearValueY);
double		calc_powsum(struct List *Lst, BOOL LinearValueY);
double		calc_sum(struct List *Lst, BOOL LinearValueY);
double		calc_xysum(void);
double		calc_lralpha(void);
double		calc_lrbeta(void);
double		calc_lrassessx(double y);
double		calc_lrassessy(double x);
double		calc_lrcorr(void);
double		calc_lrcovar(void);





/**********************************************************************/
/*                         Scanner-Prototypes                         */
/**********************************************************************/
int	yylex(void);
void	yyrestart(FILE *File);
void	count(void);
int	calc_int_value(char *s);
int	calc_hex_value(char *s, int leng);
int	calc_bin_value(char *s);
int	calc_oct_value(char *s);
int	calc_dbl_value(char *s);



/**********************************************************************/
/*                   Error-Codes for Scanner/Parser                   */
/**********************************************************************/
#define	ERR_PARSE	1
#define	ERR_UNKNOWN_CHR	2
#define	ERR_DIVBY0	3
#define	ERR_OVERFLOW	4
#define	ERR_NOMEM	5
#define	ERR_UNDERFLOW	6




/**********************************************************************/
/*                      My constant definitions                       */
/**********************************************************************/
#define Pi	  ((double) 3.141592653589793)




/**********************************************************************/
/*                        Assembler-Prototypes                        */
/**********************************************************************/
ULONG	__asm MyASL(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyASR(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyLSL(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyLSR(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyROL(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyROR(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyXOR(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyNAND(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyNOR(register __d0 ULONG In, register __d1 ULONG Out);
ULONG	__asm MyNXOR(register __d0 ULONG In, register __d1 ULONG Out);
APTR	__asm DoCreatePool(register __d0 ULONG, register __d1 ULONG, register __d2 ULONG);
void	__asm DoDeletePool(register __a0 APTR);
APTR	__asm AllocVecPool(register __a0 APTR, register __d0 ULONG);
void	__asm FreeVecPool(register __a0 APTR, register __a1 APTR);



/**********************************************************************/
/*                   Structure for ListView display                   */
/**********************************************************************/
struct	ListStruct
{
	char	Input[258];
	char	Output[258];
};




/**********************************************************************/
/*       Node to use for Standard/Linear Regression calculation       */
/**********************************************************************/
struct	DoubleNode
{
	struct	Node	Link;
	double		ValueX;
	double		ValueY;
};



/**********************************************************************/
/*                   Node for displaying constants                    */
/**********************************************************************/
struct	ConstNode
{
	char		*Constant;
	char		*Value;
	char		*Notation;
};



/**********************************************************************/
/*                         Some nice defines                          */
/**********************************************************************/

	// This is our Version string

#define	MUIVERS		"$VER:MCalc "REVISION" ("REVDATE")"


	// These are for Button/Menu IDs

enum{
	DUMMY,

	ID_QUIT,			// Quit program
	ID_ABOUT,			// Display About
	ID_PREFS,			// Open Prefs

	ID_PICKLEFT,			// Pick left entry from History
	ID_PICKRIGHT,			// Pick right entry from History
	ID_CLIPCUTLEFT,			// Clip left entry to clipboard
	ID_CLIPCUTRIGHT,		// Clip right entry to clipboard
	ID_DELHISTORY,			// Delete active entry from History

	ID_DECIMAL,			// Switch to dec display
	ID_HEXDECIMAL,			// Switch to hex display
	ID_OCTAL,			// Switch to oct display
	ID_BINARY,			// Switch to bin display

	ID_8BIT,			// Set 8-Bit Base
	ID_16BIT,			// Set 16-Bit Base
	ID_32BIT,			// Set 32-Bit Base

	ID_SIGNED,			// Switch to signed dec ouput
	ID_UNSIGNED,			// Switch to unsigned dec output

	ID_RAD,				// Radiant angles
	ID_DEG,				// Degree angles
	ID_GRAD,			// Grads angles

	ID_STDHISTORY,			// Open std.deviation history
	ID_CLOSESTD,			// Close std.deviation history
	ID_LINHISTORY,			// Open lin.regression history
	ID_CLOSELIN,			// Close lin.regression history
	ID_CONSTANTS,			// Open constants window
	ID_CLOSECONST,			// Close constants window
	ID_SELECTCONST,			// Select constant

	ID_INPUT,			// Received input from String gadget
	ID_LISTVIEW,			// Double clicked on ListView
	ID_EXEC,			// Translate input
	ID_CLEAR,			// Clear input gadget
	ID_ALLCLEAR,			// Clear input gadget AND memory

	ID_PREFS_QUIT,			// Close Prefs window
	ID_PREFS_NEW			// New Prefs set
};






/**********************************************************************/
/*                    Definitions for Online-Help                     */
/**********************************************************************/
#define	HELPFILE		"MCalc.guide"
#define	NODE_MAIN		"Main"
#define	NODE_INOUTPUT		"InputOutput"
#define	NODE_FUNCTIONS		"FuncTables"
#define	NODE_STDDEVIATION	"StdDeviation"
#define	NODE_LINREGRESSION	"LinRegression"
#define	NODE_INPUTS		"Inputs"
#define	NODE_PREFS		"Prefs"
#define	NODE_LAYOUT		"Layout"
#define	NODE_OUTPUT		"Output"
#define	NODE_HISTORY		"History"
#define	NODE_MISC		"Misc"
#define	NODE_WINDOWS		"Windows"


/**********************************************************************/
/*                   Defines for Clipboard support                    */
/**********************************************************************/
#define ID_FTXT	MAKE_ID('F','T','X','T')
#define ID_CHRS	MAKE_ID('C','H','R','S')


/**********************************************************************/
/*                       Some defines for ARexx                       */
/**********************************************************************/
#define	GET_OUTPUT		1
#define	GET_INPUT		2

#define	NORMAL_OUTPUT		1
#define	TEX_OUTPUT		2

#define	GET_ACTIVE		-1
#define	GET_TOPMOST		-2
#define	GET_BOTTOMMOST		-3

#include	"Protos.h"
#endif
