
/*======================================================================*/
/*  Calculator DISPLAY Command Routine(s)                               */
/*======================================================================*/

#include stdio

/* global flags and variables */

extern int  cmd_file_flag;
extern int  error_flag;
extern int  debug_flag;
extern int  format_precision;


/*----------------------------------------------------------------------*/
/*  Set The Display Format Precision To The Default Value               */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  parameter  user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int default_precision (options,stringcnt,stringptr,tokencnt,
                       tokenptr,character,number,parameter)
int  options,stringcnt,tokencnt,number,parameter;
char character,stringptr[],tokenptr[];
{
   format_precision = 6;
   if (debug_flag) printf("Precision:   %d\n",format_precision);
   return 1;
}


/*----------------------------------------------------------------------*/
/*  Set The Display Format Precision To The Defined Value               */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  parameter  user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int define_precision (options,stringcnt,stringptr,tokencnt,
                        tokenptr,character,number,parameter)
int  options,stringcnt,tokencnt,number,parameter;
char character,stringptr[],tokenptr[];
{
   if ((number < 1) || (number > 16))
      printf("-- Illegal precision value, precision set to default\n");
   else
   format_precision = number;

   if (debug_flag)
      {
      printf("Precision:   %d\n",format_precision);
      }
   return 1;
}


/*----------------------------------------------------------------------*/
/*  Display All Command File Commands                                   */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  parameter  user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int display_file (options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,parameter)
int  options,stringcnt,tokencnt,number,parameter;
char character,stringptr[],tokenptr[];
{
   cmd_file_flag = TRUE;

   if (debug_flag)
      printf ("Token:      %.*s\n",tokencnt,tokenptr);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  Display No Command File Commands                                    */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  parameter  user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int display_nofile (options,stringcnt,stringptr,tokencnt,
                    tokenptr,character,number,parameter)
int  options,stringcnt,tokencnt,number,parameter;
char character,stringptr[],tokenptr[];
{
   cmd_file_flag = FALSE;

   if (debug_flag)
      printf ("Token:      %.*s\n",tokencnt,tokenptr);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  Unknow Display Parameter                                            */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  parameter  user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int display_unknown_parameter (options,stringcnt,stringptr,tokencnt,
                               tokenptr,character,number,parameter)
int  options,stringcnt,tokencnt,number,parameter;
char character,stringptr[],tokenptr[];
{

   printf ("-- Illegal display parameter\n");

   return 1;
}
