home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / TDE32.ZIP / CFGHELP.C < prev    next >
C/C++ Source or Header  |  1993-11-13  |  2KB  |  87 lines

  1. /*
  2.  * This module contains all the routines needed to create a new help
  3.  * screen.  The new help screen is read from a file which must exist before
  4.  * executing this routine.
  5.  *
  6.  * Program Name:  tdecfg
  7.  * Author:        Frank Davis
  8.  * Date:          October 5, 1991
  9.  */
  10.  
  11. #include <io.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15.  
  16. #include "tdecfg.h"
  17. #include "cfghelp.h"
  18.  
  19. extern struct vcfg cfg;
  20. extern FILE *tde_exe;                  /* FILE pointer to tde.exe */
  21. extern long help_offset;
  22.  
  23. static WINDOW *w_ptr;
  24.  
  25.  
  26.  
  27. /*
  28.  * Name:    tdehelp
  29.  * Date:    October 1, 1991
  30.  * Notes:   Set up most of the window global variables.
  31.  */
  32. void tdehelp( void )
  33. {
  34. int c;
  35. int i;
  36. char line[200];
  37. char out_line[82];
  38. char fname[82];
  39. char *rc;
  40. FILE *help_file;                  /* FILE pointer to help screen */
  41. long offset;
  42.  
  43.  
  44.    cls( );
  45.    show_box( 0, 0, help_screen, NORMAL );
  46.    xygoto( 42, 14 );
  47.    c = getkey( );
  48.    while (c != '1' && c != '2')
  49.       c = getkey( );
  50.    if (c == '1') {
  51.       puts( "" );
  52.       puts( "" );
  53.       puts( "" );
  54.       puts( "Enter file name that contains new help screen :" );
  55.       gets( fname );
  56.       if ((c = access( fname, EXIST )) != 0) {
  57.          puts( "\nFile not found.  Press any key to continue." );
  58.          c = getkey( );
  59.          cls( );
  60.          return;
  61.       } else if ((help_file = fopen( fname, "r" )) == NULL ) {
  62.          puts( "\nCannot open help file.  Press any key to contine." );
  63.          c = getkey( );
  64.          cls( );
  65.          return;
  66.       }
  67.       offset = help_offset + 8;
  68.       rc = fgets( line, 100, help_file );
  69.       for (c=0; c<25 && rc != NULL; c++) {
  70.          memset( out_line, '\0', 82 );
  71.          for (i=0; i<80 && line[i] != '\n'; i++)
  72.              out_line[i] = line[i];
  73.          fseek( tde_exe, offset, SEEK_SET );
  74.          fwrite( out_line, sizeof( char ), 81, tde_exe );
  75.          offset += 81;
  76.          rc = fgets( line, 100, help_file );
  77.       }
  78.       fclose( help_file );
  79.       puts( "" );
  80.       puts( "" );
  81.       puts( "" );
  82.       puts( "New help screen successfully installed.  Press any key to continue." );
  83.       c = getkey( );
  84.    }
  85.    cls( );
  86. }
  87.