home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / t_power / demohelp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-02-07  |  2.5 KB  |  111 lines

  1. {Activate the following define if you've created DEMOHELP.OBJ}
  2. { $DEFINE BoundInHelp}
  3.  
  4. {$IFDEF BoundInHelp}
  5. {Context sensitive help available only if help is bound into application}
  6. {Activate the following define to try context-sensitive help}
  7. { $DEFINE ContextSensitive}
  8. {$ENDIF}
  9.  
  10. {$R-,S-}
  11. program HelpDemo;
  12. uses
  13.   Dos,
  14.   TPDos,
  15.   TPString,
  16.   TPCrt,
  17.   TPWindow,
  18.   {$IFDEF UsingPickUnit}
  19.   TPPick,
  20.   {$ENDIF}
  21.   TPHelp;
  22. var
  23.   H              : HelpPtr;
  24.   Status         : Word;
  25.   I              : Word;
  26.   S              : string;
  27.   Ch             : Char;
  28.  
  29.   {$IFDEF BoundInHelp}
  30.   {$L demohelp.obj}
  31.   procedure DemoHelp; external;
  32.   {$ENDIF}
  33.  
  34.   procedure ActivateHelp;
  35.     {-Cheap pick replacement}
  36.   var
  37.     Ch             : Char;
  38.   begin
  39.     WriteLn('Choose help topic:');
  40.     WriteLn('  0. Quit, 1. Initializing, 2. Displaying, 3. Compiling, 4. Binding');
  41.     repeat
  42.       repeat
  43.         Ch := readkey;
  44.       until Ch in ['0'..'4'];
  45.       if Ch <> '0' then
  46.         if not ShowHelp(H, Ord(Ch)-Ord('0')) then
  47.           Ch := '0';
  48.     until Ch = '0';
  49.   end;
  50.  
  51. begin
  52.   {$IFDEF BoundInHelp}
  53.   Status := OpenHelpMem(@DemoHelp, 2, 2, 22, H);
  54.   {$ELSE}
  55.   Status := OpenHelpFile('DEMOHELP.HLP', 2, 2, 22, H);
  56.   {$ENDIF}
  57.   if Status <> 0 then begin
  58.     case Status of
  59.       2 : WriteLn('Help file DEMOHELP.HLP not found');
  60.       100 : WriteLn('Unexpected end of file reading DEMOHELP.HLP');
  61.       106 : WriteLn('Help file has invalid format');
  62.       203 : WriteLn('Insufficient heap space available');
  63.     else
  64.       WriteLn('Help initialization error ', Status);
  65.     end;
  66.     Halt;
  67.   end;
  68.  
  69.   {$IFDEF ContextSensitive}
  70.  
  71.   {Install context sensitive help - pop up with <F1>}
  72.   SetContextHelp(H, $3B00);
  73.  
  74.   CurrentTopic := 1;
  75.   WriteLn('Current topic "Initializing". Using CRT ReadLn, F1 for help');
  76.   ReadLn(S);
  77.  
  78.   CurrentTopic := 2;
  79.   WriteLn('Current topic "Displaying". Using ReadKey, F1 for help');
  80.   Ch := readkey;
  81.  
  82.   CurrentTopic := 3;
  83.   WriteLn('Current topic "Compiling". Using ReadKeyWord, F1 for help');
  84.   I := readkeyword;
  85.  
  86.   CurrentTopic := 4;
  87.   Assign(Output, '');
  88.   Rewrite(Output);
  89.   Assign(Input, '');
  90.   Reset(Input);
  91.   WriteLn('Current topic "Binding". Using DOS ReadLn, F1 for help');
  92.   ReadLn(S);
  93.  
  94.   {$ELSE}
  95.  
  96.   {Not context-sensitive help}
  97.   {$IFDEF UsingPickUnit}
  98.   repeat
  99.     I := PickHelp(H, 2, 2, 10, 1);
  100.     if I <> 0 then
  101.       if not ShowHelp(H, I) then
  102.         WriteLn('error showing help ', status);
  103.   until I = 0;
  104.  
  105.   {$ELSE}
  106.   ActivateHelp;
  107.   {$ENDIF}
  108.   {$ENDIF}
  109.  
  110. end.
  111.