/*======================================================================*/
/*  Calculator HELP Comand Routine(s)                                   */
/*======================================================================*/

#include stdio
#include descrip

/* HLP definitions */

#define HLP$M_PROMPT    0x1
#define HLP$M_PROCESS   0x2
#define HLP$M_GROUP     0x4
#define HLP$M_SYSTEM    0x8
#define HLP$M_LIBLIST   0x10
#define HLP$M_HELP      0x20

/* global flags and variables */

extern int debug_flag;
extern int error_flag;

/* local flags, variables and definitions */

int LIB$GET_INPUT();
int LIB$PUT_OUTPUT();

struct dsc$descriptor subject;

$DESCRIPTOR (hlplib,"CALCULATOR_HELP");


/*----------------------------------------------------------------------*/
/*  Display The Token For A Successful Transition                       */
/*                                                                      */
/*  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                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int display_help (options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   int flags,status;

   if (error_flag) return 1;

   if (debug_flag == TRUE)
      printf("Help:       %.*s\n",stringcnt,stringptr);

      subject.dsc$b_class   = DSC$K_CLASS_S;
      subject.dsc$b_dtype   = DSC$K_DTYPE_T;
      subject.dsc$w_length  = stringcnt;
      subject.dsc$a_pointer = stringptr;

      flags = HLP$M_PROMPT | HLP$M_PROCESS |
              HLP$M_GROUP  | HLP$M_SYSTEM;

      status = LBR$OUTPUT_HELP(LIB$PUT_OUTPUT,
                               0,
                               &subject,
                               &hlplib,
                               &flags,
                               LIB$GET_INPUT);

      if ((status&1)!=1)
         {
         error_flag = TRUE;
         printf("-- Error while trying to access help library\n");
         }
   return 1;
}
