home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / newhelp.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  3KB  |  114 lines

  1. extern char *tk[500];
  2. extern char inbuff[300];
  3. extern char tkbuff[500];
  4. extern char space_str[3];
  5. extern int ntk;
  6.  
  7. do_help(char *hstr)
  8. {
  9.     char ss[90];
  10.     strcpy(ss,"gle graph ");
  11.     strcat(ss,hstr);
  12.     do_help2(ss);
  13. }
  14. do_help2(char *hstr)
  15. {
  16.     FILE *hfile;
  17.     int i,yy,cp,match;
  18.     char hbuff[90],mstr[80],mstr2[80];
  19.     char *page;
  20.     char h[90];
  21.     char *hfilename="graph.hlp";
  22.  
  23.     page = mymallocz(sizeof(char *) * 200);
  24.     npage = 0;
  25.  
  26.     strcpy(h,hstr);
  27. help_again:;
  28.     token_data(h,tk,&ntk,tkbuff);
  29.     for (i=1;i<=ntk;i++) strlwr(tk[i]);
  30.  
  31.     scr_menuval();
  32.     clrscr();
  33.  
  34.     if (*tk[2] == 'd' && strlen(tk[2])==2) tk[2] = "dn";
  35.     if (strcmp(tk[3],"yaxis")==0) tk[3] = "xaxis";
  36.     if (strcmp(tk[3],"y2axis")==0) tk[3] = "xaxis";
  37.     if (strcmp(tk[3],"x2axis")==0) tk[3] = "xaxis";
  38.     if (strcmp(tk[3],"ylabels")==0) tk[3] = "xlabels";
  39.     if (strcmp(tk[3],"y2labels")==0) {tk[3] = "xlabels"; k2 = "off";}
  40.     if (strcmp(tk[3],"x2labels")==0) {tk[3] = "xlabels"; k2 = "off";}
  41.     if (strcmp(tk[3],"ynames")==0) tk[3] = "xnames";
  42.     if (strcmp(tk[3],"y2names")==0) tk[3] = "xnames";
  43.     if (strcmp(tk[3],"x2names")==0) tk[3] = "xnames";
  44.     if (strcmp(tk[3],"ytitle")==0) tk[3] = "xtitle";
  45.     if (strcmp(tk[3],"y2title")==0) tk[3] = "xtitle";
  46.     if (strcmp(tk[3],"x2title")==0) tk[3] = "xtitle";
  47.     if (strcmp(tk[3],"title")==0) tk[3] = "xtitle";
  48.  
  49.     gotoxy(1,1); wprintf("GLE help ");
  50.     for (i=1;i<=ntk;i++) wprintf("{%s} ",tk[i]);
  51.     scr_menubg();
  52.     hfile = fopen(gledir(hfilename),"rt");
  53.     if (hfile==NULL) perror("Unable to open graph.hlp ");
  54.  
  55.     /* Find match for each key word, display that section of file
  56.     and find rest of key words at that level */
  57.  
  58.     match = 1; /* trying to match a level one word */
  59.     for (;!feof(hfile);) {
  60.       if (fgets(hbuff,90,hfile)!=NULL) {
  61.         sprintf(mstr,"%d",match);
  62.         sprintf(mstr2,"%d",match-1);
  63.         if (match>ntk) {
  64.           if (strncmp(hbuff,mstr2,1)==0) { /* End of section */
  65.             goto got_help;
  66.           }
  67.           if (strncmp(hbuff,mstr,1)==0) { /* Sub topic */
  68.             capture = false;
  69.             strtok(hbuff," \h\n");
  70.             strcat(subtopic,strtok(NULL," \h\n"));
  71.             strcat(subtopic," ");
  72.           }
  73.         } else if (strncmp(hbuff,mstr,1)==0) { /* correct level */
  74.             capture = true;
  75.             strtok(hbuff," \h\n");
  76.             strcpy(fk1,strtok(NULL," \h\n"));
  77.             if (strncmp(fk1,tk[match],strlen(tk[match]))==0) {
  78.                 match++;
  79.             }
  80.         } else if (capture) page[npage++] = sdup(hbuff);
  81.       }
  82.     }
  83.     fclose(hfile);
  84.     scr_menuval();
  85.     gotoxy(1,9);
  86.     wprintf("Help text not found sorry ??? \n");
  87.     text_inkey();
  88.     return;
  89. got_help:;
  90.  
  91.     /* Add subtopic's onto page[npage] */
  92.     page[npage++] = sdup("Subtopics:");
  93.     page[npage++] = sdup(subtopic);
  94.  
  95.     cp = 0; /* start on first page */
  96.     yy = cp+22;
  97. next_page:;
  98.     if (yy>=npage) yy = npage;
  99.     for (i==cp;i<yy;i++) {
  100.         strcpy(hbuff,page[i+cp]);
  101.         gotoxy(1,i+3); cputs(tabtospace(hbuff));
  102.     }
  103.     scr_menuval();
  104.     gotoxy(1,24);
  105.     read_command(hbuff,"Subtopic [return to continue] ");
  106.     scr_menubg();
  107.     strupr(hbuff);
  108.     if (strlen(hbuff)!=0) {
  109.         strcat(h," ");
  110.         strcat(h,hbuff);
  111.         goto help_again;
  112.     }
  113. }
  114.