home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / help / tphelp / demohelp.pas 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.