Sindbad~EG File Manager
/* M. Beeson, for Mathpert
last modified 1.23.98 before version 1.624
last modified 6.17.04
*/
/* Note, optable.rh is prepared from this file by makerh.exe.
There must be no multi-line comments in the definition of
optable: if there are, put comment symbols on each line.
Otherwise, makerh can't cope. It ignores the part of the file
before and after optable, however.
*/
/*___________________________________________________________________*/
/* optable is the table that gives the names of the (actual code for the)
operators on the menus. It must match the array menutext in mtext.c.
It is referred to in model.c too so don't change its declaration, but
it's ok to add more items */
#define AUTOMODE_DLL
#include <stdlib.h>
#include "globals.h"
#include "mtext.h" /* for MAXMENUS */
#include "ops.h" /* prototypes of MATHPERT operators */
#include "trig.h"
#include "calc.h"
#include "series.h"
#include "operator.h" /* automode_only */
actualop StaticOptable[MAXMENUS][16];
actualop StaticBrother[3][16];
actualop testop = arithmetic; //DEBUG
/* According to Jeff Richter, this should have a different value than
testop2 a few lines below which has automatic rather than static
storage class. But, it gets the same value, the large one,
while 'arithmetic' in its home dll, algebra.dll, gets a small value.
*/
/*______________________________________________*/
MEXPORT_AUTOMODE void init_optable(void)
/* copy optable from the stack to StaticOptable if
it hasn't already been done. */
{ static int flag; /* set when the copying has been done */
int i,j;
actualop testop2 = arithmetic; // DEBUG
#ifdef __WIN32__
#include "automode\opdef.c" /* definition of optable */ // use this line for Windows
#else
#include "automode/extra/opdef.c" /* definition of optable */ // use this line for Unix
#endif
if(flag)
return;
for(i=0;i<MAXMENUS;i++)
{ for(j=0;j<16;j++)
StaticOptable[i][j] = optable[i][j];
}
for(i=0;i<3;i++)
{ for(j=0;j<16;j++)
StaticBrother[i][j] = brother[i][j];
}
flag = 1;
}
/*_________________________________________________________*/
MEXPORT_AUTOMODE actualop * access_optable(int n)
/* access_optable(i)[j] replaces optable[i][j]
from outside symbols.dll */
{
return (actualop *) StaticOptable[n];
}
/*_________________________________________________________*/
MEXPORT_AUTOMODE actualop get_brother(int menu, int i)
/* return brother[0][i], brother[1][i], or brother[2][i]
according as menu is automode_only, automode_only2, automode_only3
*/
{
switch(menu)
{ case automode_only:
return StaticBrother[0][i];
case automode_only2:
return StaticBrother[1][i];
case automode_only3:
return StaticBrother[2][i];
}
return NULL;
}
/*__________________________________________________________*/
MEXPORT_AUTOMODE int cousins(operation a, operation b)
/* return 1 if a and b have the same effect, so that
user could have chosen either one. This is called by
think_ahead when generating error messages: if b is what
automode would do at step 2 and user chooses a at step 1,
user will get an error message the same as if he chose b
at step 1. It is presumed that a and b are not equal
(as operators, though the associated actualop might be the
same). The automode-op comes in a and the user's op
comes in b; the function is not necessarily symmetrical
as operators never used in auto mode don't have to be
listed in b position.
*/
{ actualop A, B;
A = StaticOptable[a.men][a.choice-1];
B = StaticOptable[b.men][b.choice-1];
if((void *) A == (void *) B)
return 1; /* same code at different places in menu */
if( (void *) A == (void *) collectall )
return (void *) B == (void *) collectterms;
if( (void *) A == (void *) collectterms )
return (void *) B == (void *) collectall;
if( (void *) A == (void *) commondenom )
{ if( (void *) B == (void *) commondenomandsimp ||
(void *) B == (void *) commondenominfraction ||
(void *) B == (void *) commondenom2 ||
(void *) B == (void *) findcommondenom ||
(void *) B == (void *) commondenomandsimp2
)
return 1;
else
return 0;
}
if( (void *) A == (void *) commondenomandsimp )
{ if( (void *) B == (void *) commondenom ||
(void *) B == (void *) commondenominfraction ||
(void *) B == (void *) commondenom2 ||
(void *) B == (void *) commondenomandsimp2 ||
(void *) B == (void *) findcommondenom
)
return 1;
else
return 0;
}
if( (void *) A == (void *) findcommondenom )
{ if( (void *) B == (void *) commondenomandsimp ||
(void *) B == (void *) commondenom ||
(void *) B == (void *) commondenominfraction ||
(void *) B == (void *) commondenom2 ||
(void *) B == (void *) commondenomandsimp2
)
return 1;
else
return 0;
}
return 0;
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists