home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: Science
/
Science.zip
/
imdisp79.zip
/
HELP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-15
|
3KB
|
131 lines
/*** IMDISP module HELP.C
HELP.C contains the command which services help requests from
the IMDISP main menu. All help text for new commands goes here.
Adapted from the original HELP.C to use external help file
IMDISP.HLP ala Lee Brotzman's FTB program/
***/
#define __MSC
/* * * * INCLUDE files * * * */
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include "imdef.h"
#include "imdisp.h"
#include "imdutil.h"
#include "dispio.h"
#include "labutil.h"
#include "textutil.h"
/*
External data
*/
void Help(void)
/*
Print help information on given topic. The help is gotten from a text
file called pointed to by the FILE structure helpfile. Each topic is
delimited by a record beginning with a period, '.', followed by the name
of the topic. All records up to the next topic heading are listed to
the screen.
*/
{
char inrec[81];
int linecnt;
int length;
char ch;
char *command, temp[81];
char *string;
strcpy(temp, CommandString);
command = strtok( temp, " ");
command = strtok( NULL, " ");
if (command == NULL) /* Default help command is "HELP HELP" */
{
strcpy(temp, "HELP");
command = strtok(temp," ");
}
if(helpfile == NULL)
{
sprintf( inrec, "Warning: help file %s not open.", helpfilename);
StatusLine(1, inrec);
return;
}
rewind(helpfile);
linecnt = 0;
while( !feof(helpfile) )
{
fgets(inrec, 80, helpfile);
if (inrec[0] == '.')
{
string = strrtrim( inrec );
strcpy( inrec, string);
if (match(command, &inrec[1]))
{
if (OneScreen)
{
ClearDisplay (0);
TextLine = TextHeight + 5;
TextSample = 1;
}
fgets(inrec, 80, helpfile);
while ((inrec[0] != '.') && !feof(helpfile))
{
string = strrtrim( inrec );
strcpy( inrec, string);
length = strlen(inrec);
if (length == 0)
{
TextLine += TextHeight+5;
TextSample = 1;
}
else
WriteText(inrec);
fgets(inrec, 80, helpfile);
if ( (TextLine + 2*TextHeight) >= dispnl)
{
WriteText("Press RETURN to continue, any key to quit: ");
while(!kbhit);
if ((ch = getch()) == 0)
ch = 0x80 | getch();
if (ch != 13) /* don't abort if <CR> */
{
return;
}
ClearDisplay (0);
TextLine = TextHeight + 5;
TextSample = 1;
}
}
return;
}
}
}
/*
No match was found, list HELP topics
*/
strcpy(CommandString, "HELP");
Help();
}