home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 1.ddi / EXAMPLE.EXE / CSCAPE / EXAMPLE / DEMOHELP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-12  |  2.7 KB  |  121 lines

  1. /*    
  2.     demohelp.c     
  3.  
  4.     Copyright (c) 1988, by Oakland Group, Inc.
  5.     ALL RIGHTS RESERVED.
  6.  
  7.     This program demonstrates the use of the C-scape help system.
  8.     The help file "demohelp.hlp" is used.
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <cscape.h>
  13.  
  14. #include <helpdecl.h>
  15. #include <popdecl.h>
  16.  
  17. /*** Note: C-scape uses the _arg macro to turn off prototyping 
  18.      for older compilers */
  19.  
  20. int test(_arg4(int *, long *, long *, char *));
  21.  
  22. struct hx_struct hxd = { '\x07', '\x0f', '\x70', '\x07', bd_xref};
  23.  
  24. void main()
  25. {
  26.     FILE *fp;
  27.  
  28.     char     string[25];
  29.     int     i = 0;
  30.     long     l = 0L;
  31.     long     money = 0L;
  32.  
  33.     string[0] = '\0';
  34.  
  35.     /* Initialize the display */
  36.     disp_Init(def_ModeText, NULL);
  37.  
  38.     fp = fopen("demohelp.hlp", "rb");
  39.  
  40.     if (fp == NULL) {
  41.         pop_Prompt("Unable to open help file.\n", -1, -1, -1, 26, (char) '\x70', bd_2);
  42.  
  43.         /* Close down the display interface */
  44.         disp_Close();
  45.         return;
  46.     }
  47.  
  48. /*
  49.     help_Init sets up the help system.
  50.     The first argument is a pointer to the help file.
  51.     The second argument is a pointer to the help display function.
  52.     The third argument tells the help system how much space to allocate
  53.     to hold the help messages.  This is the maximum size of a help message.
  54.  
  55.     The cscape field functions automatically call help when F1 is pressed.
  56.     (see fnspec.c)
  57. */
  58.  
  59.     help_Init(fp, help_Xref, 6000, (char *) &hxd);
  60.  
  61.     test(&i, &l, &money, string);
  62.  
  63.     fclose(fp);
  64.  
  65.     /* Close down the display interface */
  66.     disp_Close();
  67. }
  68.  
  69. int test(i, l, money, s)
  70.     int *i;
  71.     long *l;
  72.     long *money;
  73.     char *s;
  74. {
  75.     menu_type    menu;
  76.     sed_type    sed;
  77.     int         ret;
  78.  
  79.     menu = menu_Open();
  80.  
  81.     menu_Printf(menu, "@c[\x70]");
  82.     menu_Printf(menu, "@p[0,0]int:");
  83.     menu_Printf(menu, "@p[2,0]long:");
  84.     menu_Printf(menu, "@p[4,0]money:");
  85.     menu_Printf(menu, "@p[6,0]string:");
  86.     menu_Printf(menu, "@p[0,11]@fd2[####]",
  87.       i, &int_funcs, "Enter an integer (0-100)", "(0,100)");
  88.     menu_Printf(menu, "@p[2,7]@fd2[########]",
  89.       l, &long_funcs, "Enter a long (0-10000)", "(0,10000)");
  90.     menu_Printf(menu, "@p[4,7]@fd2[########]",
  91.       money, &cmoney_funcs, "Enter the amount (0-100.00)", "(0,10000)");
  92.  
  93.     menu_Printf(menu, "@p[6,8]@fd3[################]   ",
  94.       s, &string_funcs, "Enter a string", NULL, "^");
  95.  
  96.     menu_Flush(menu);
  97.  
  98.     sed = sed_Open(menu);
  99.     sed_SetColors(sed, '\x70', '\x70', '\x07');
  100.     sed_SetBorder(sed, bd_std);
  101.     sed_SetBorderTitle(sed, "Press F1 for help");
  102.     sed_SetPosition(sed, 7, 19);
  103.  
  104.     sed_Repaint(sed);
  105.  
  106. /*
  107.     The label is used to determine which help chapter to use for the sed.
  108.     The field number determines which paragraph to use.
  109.  
  110.     (see demohelp.hlp)
  111. */
  112.     sed_SetLabel(sed, 1);
  113.  
  114.     ret = sed_Go(sed);
  115.  
  116.     menu_Close(menu);
  117.     sed_Close(sed);
  118.     return(ret);
  119. }
  120.  
  121.