|
|
DataMuseum.dkPresents historical artifacts from the history of: DANOSI |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DANOSI Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 7226 (0x1c3a)
Types: TextFile
Names: »HELP.PAS«
└─⟦e2123b2a1⟧ Bits:30010498 DVBS1.SW2103.src.1.8-1 Pascal TOOLS JTAS 1989-04-26 LEIF NIELSEN E.d.
└─⟦this⟧ »UNITS\HELP.PAS«
{$R-} {Range checking off}\r
{$B+} {Boolean complete evaluation on}\r
{$S+} {Stack checking on}\r
{$I+} {I/O checking on}\r
{$N-} {No numeric coprocessor}\r
\r
UNIT help;\r
\r
INTERFACE\r
\r
USES\r
Crt, \r
Dos, \r
dosutil;\r
\r
CONST\r
HelpFileName : STRING = '';\r
\r
PROCEDURE ShowHelp;\r
\r
\r
{===========================================================================}\r
\r
IMPLEMENTATION\r
\r
\r
\r
{ Some procedures to overload the Turbo Pascals selection of yellow as }\r
{ the default for low video. }\r
{ Procedure Help dislpays the help file HelpFileName for the user. }\r
CONST\r
HelpFileExt: STRING = 'HLP';\r
MaxLineCount = 200;\r
\r
{PROCEDURE LowVideo;\r
\r
BEGIN\r
TextColor(LightGray);\r
END;\r
\r
\r
PROCEDURE HighVideo;\r
\r
BEGIN\r
TextColor(White);\r
END;}\r
\r
\r
PROCEDURE ShowHelp;\r
\r
\r
TYPE\r
str80 = STRING[80];\r
Pages = ARRAY[0..MaxLineCount] OF str80;\r
\r
VAR\r
H : text;\r
Line : STRING[80];\r
Ch : Char;\r
LineCounter, EndOfFile, ErrorResult, BeginPage,\r
J : Integer;\r
Bold : boolean;\r
Buffer : ^Pages;\r
AuxName :\r
STRING;\r
\r
PROCEDURE DisplayMessage;\r
\r
BEGIN\r
GotoXY(3, 25);\r
LowVideo;\r
write('Press ');\r
HighVideo;\r
Write('''PgDn''');\r
LowVideo;\r
Write(' for next page ');\r
HighVideo;\r
Write('''PgUp''');\r
LowVideo;\r
Write(' for previous, ');\r
HighVideo;\r
Write('''Esc''');\r
LowVideo;\r
Write(' to exit Help file.');\r
END;\r
\r
{ Procedure GetPages reads the help file from disk into an array of a }\r
{ dynamicly allocated array. NOTE : the number of lines read in is kept }\r
{ in the zero'th index of the array. }\r
\r
PROCEDURE GetPages;\r
\r
VAR\r
st : STRING[10];\r
count : integer;\r
\r
BEGIN\r
count := 1;\r
Assign(H, HelpFileName);\r
Reset(H);\r
WHILE NOT Eof(H) DO\r
BEGIN\r
Readln(H, Buffer^[count]);\r
count := count + 1;\r
IF NOT eof(H) AND ( count > MaxLineCount ) THEN\r
BEGIN\r
Writeln('Internal HELP buffer too small (', MaxLineCount:1, ' lines)');\r
Halt;\r
END;\r
END;\r
close(H);\r
Str(count, st);\r
Buffer^[0] := st;\r
END;\r
\r
\r
\r
BEGIN\r
LineCounter := 1; { Initialize line counter}\r
IF HelpFileName = '' THEN\r
BEGIN\r
IF EnvStrVal('HelpDir') <> '' THEN\r
BEGIN\r
AuxName := ProgFileName;\r
WHILE Pos('\', AuxName) <> 0 DO Delete(AuxName, 1, Pos('\', AuxName));\r
Delete(AuxName, Pos('.', AuxName)+1, 255);\r
HelpFileName := EnvStrVal('HelpDir')+AuxName+HelpFileExt;\r
END\r
ELSE\r
BEGIN\r
AuxName := ProgFileName;\r
J := Length(AuxName);\r
WHILE AuxName[J] <> '.' DO J := J-1;\r
Delete(AuxName, J+1, 255);\r
HelpFileName := AuxName+HelpFileExt;\r
END;\r
END;\r
IF FileExist(HelpFileName) THEN\r
BEGIN\r
New(Buffer); { Allocate dynamic array }\r
GetPages; { Read in Help File }\r
Val(Buffer^[0], EndOfFile, ErrorResult); { EndOfFile := # of Lines}\r
TextColor(White);\r
WHILE LineCounter < EndOfFile DO\r
BEGIN\r
BeginPage := LineCounter - 1;\r
IF BeginPage < 1 THEN { If Previous page is called while on }\r
BeginPage := 1; { first page, Beginpage is off by 1. }\r
ClrScr;\r
Bold := false;\r
LowVideo;\r
Line := Buffer^[LineCounter]; { Get first line of current page. }\r
\r
{ This while loop steps through the array looking for the end of }\r
{ page indicator '.PA', writing out each line as it goes. }\r
\r
WHILE (LineCounter < EndOfFile) AND (Line <> '.PA') DO\r
BEGIN\r
Write(' ');\r
FOR J := 1 TO Length(Line) DO\r
BEGIN\r
IF Line[J] = ^B THEN { Check for bold face type }\r
BEGIN\r
Bold := NOT Bold; { Toggle Bold type }\r
IF Bold THEN\r
HighVideo\r
ELSE\r
LowVideo;\r
END\r
ELSE\r
write(Line[J]);\r
END; { End for loop - have written entire line }\r
Writeln;\r
LineCounter := LineCounter + 1;\r
Line := Buffer^[LineCounter]; { Get next line }\r
END; { end while }\r
DisplayMessage;\r
REPEAT\r
Ch := ReadKey;\r
UNTIL Upcase(Ch) IN ['P', 'N', #0, #27];\r
IF Ch = #0 THEN Ch := ReadKey;\r
CASE UpCase(Ch) OF\r
'I', { PgUp }\r
'P' : BEGIN { Get start of previous page }\r
REPEAT\r
BeginPage := BeginPage - 1;\r
UNTIL (Buffer^[BeginPage] = '.PA') OR (BeginPage < 1);\r
LineCounter := BeginPage + 1;\r
END;\r
'Q', { PgDn }\r
'N' : IF LineCounter = EndOfFile THEN\r
BEGIN\r
IF BeginPage = 1 THEN\r
LineCounter := 1\r
ELSE\r
LineCounter := BeginPage + 1 { Stay on last page }\r
END\r
ELSE\r
LineCounter := LineCounter + 1; { Get start of next page }\r
#27 : BEGIN\r
LineCounter := EndOfFile; { force counter to end of file }\r
WriteLn;\r
END;\r
END;\r
END; { end while }\r
Dispose(Buffer); { Deallocate dynamic array }\r
Exit; { Return to Spread Sheet }\r
END { End if then statement }\r
ELSE { Help file did not exist }\r
BEGIN\r
GoToXY(2, 25);\r
J := Length(HelpFileName);\r
WHILE HelpFileName[J] <> '.' DO J := J-1;\r
Delete(HelpFileName, J, 255);\r
WHILE Pos('\', HelpFileName) > 0 DO\r
Delete(HelpFileName, 1, Pos('\', HelpFileName));\r
WriteLn('No help available for command ', HelpFileName, '. Press <RETURN>');\r
REPEAT Ch :=ReadKey UNTIL Ch=^M;\r
Exit;\r
END;\r
END; { End procedure Help }\r
\r
\r
END.\r