home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / tplib21.zip / INSTALL.EXE / EXENHCON.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-30  |  12KB  |  356 lines

  1. (* Example program: ENHCON unit *)
  2.  
  3. PROGRAM EXENHCON;
  4.  
  5. USES
  6.     STRINGS,CRT,ENHCON;
  7.  
  8. VAR
  9.     s:  STRING;
  10.  
  11.  
  12. PROCEDURE ExOpt1;
  13.  
  14.     VAR
  15.         ExFormat:   EditFormatRec;
  16.         s:          STRING;
  17.         ch:         CHAR;
  18.  
  19.     BEGIN
  20.         WITH ExFormat DO
  21.             BEGIN
  22.                 IF ColorDisplay THEN
  23.                     Attribute := LightGray + Blue * 16
  24.                 ELSE
  25.                     Attribute := MonoReverse;
  26.                 StartChar := NUL;
  27.                 EndChar := NUL;
  28.                 MarkerAttr := 0;
  29.                 AllowChars := StandardChars;
  30.                 ExitKeys := [CR, KeyF10];
  31.                 EditKey := NUL;
  32.                 RestoreKey := ESC;
  33.                 AbortKey := ESC;
  34.                 Flags := EdFlagInsStat + EdFlagFirstClr + EdFlagHideCrsr;
  35.             END;
  36.         CursorInsert := TRUE;
  37.         ClrScr;
  38.         WriteLn('Enter a new string or edit the existing one, then press');
  39.         WriteLn('RETURN or F10 to complete the edit.  Notice how the code');
  40.         WriteLn('returned by EditString indicates which key was pressed.');
  41.         WriteLn('You can use the Escape key to abandon changes or to abort');
  42.         WriteLn('the edit.  In this example, aborting the edit will return');
  43.         WriteLn('you to the example menu.');
  44.         s := 'This is the initial string';
  45.         REPEAT
  46.             GotoXY(20,14);
  47.             ch:=EditString (ExFormat, s, 30);
  48.             GotoXY(20,20);
  49.             Write('Returned character code = ', HexStr(Ord(ch),2), ' hex.');
  50.             Delay(3000);
  51.             GotoXY(20,20);
  52.             ClrEOL;
  53.         UNTIL ch = ESC;
  54.     END;  { ExOpt1 }
  55.  
  56.  
  57. PROCEDURE ExOpt2;
  58.  
  59.     VAR
  60.         i:          LongInt;
  61.         ch:         CHAR;
  62.         ExFormat:   EditFormatRec;
  63.  
  64.     BEGIN
  65.         WITH ExFormat DO
  66.             BEGIN
  67.                 Attribute := 0;
  68.                 StartChar := #16;
  69.                 EndChar := #17;
  70.                 IF ColorDisplay THEN
  71.                     MarkerAttr := LightRed
  72.                 ELSE
  73.                     MarkerAttr := MonoIntense;
  74.                 ExitKeys := [CR, KeyF10];
  75.                 EditKey := NUL;
  76.                 RestoreKey := ESC;
  77.                 AbortKey := ESC;
  78.                 NumFormat := '$PC12:2';
  79.                 SignalError := StdSignalError;
  80.                 Flags := EdFlagInsStat + EdFlagFirstClr + EdFlagHideCrsr;
  81.             END;
  82.         CursorInsert := TRUE;
  83.         ClrScr;
  84.         WriteLn('This example shows how EditInt can be used with a');
  85.         WriteLn('typical application - Amounts of money.');
  86.         WriteLn('As with the previous example, use RETURN or F10 to complete');
  87.         WriteLn('the edit.  You can use the Escape key to abandon changes');
  88.         WriteLn('or return to the menu, as before.  The amount of money is ');
  89.         WriteLn('represented as a LongInt variable, and two assumed decimal');
  90.         WriteLn('places are used.  The minimum and maximum allowable values');
  91.         WriteLn('are plus and minus $5,000.');
  92.         i := 100;
  93.         REPEAT
  94.             GotoXY(20,14);
  95.             ch:=EditInt (ExFormat, i, -500000, 500000);
  96.             GotoXY(20,20);
  97.             WriteLn('Returned code = ', HexStr(Ord(ch),2), ' hex.');
  98.             GotoXY(20,22);
  99.             WriteLn('Value of integer is now ', i:8);
  100.             Delay(6000);
  101.             GotoXY(20,20);
  102.             ClrEOL;
  103.             GotoXY (20,22);
  104.             ClrEOL;
  105.         UNTIL ch=ESC;
  106.     END; { ExOpt2 }
  107.  
  108.  
  109. PROCEDURE ExOpt3;
  110.  
  111.     VAR
  112.         w1, w2, w3:   WindowDefinition;
  113.         k:  BYTE;
  114.         ch: CHAR;
  115.  
  116.     PROCEDURE WaitForKey;
  117.  
  118.         VAR
  119.             ch: CHAR;
  120.  
  121.         BEGIN
  122.             WriteWindow ('Press any key...');
  123.             ch := ReadKey;
  124.             WriteWindow ('                ');
  125.         END;
  126.  
  127.  
  128.     BEGIN
  129.         CheckBreak := FALSE;
  130.         ClrScr;
  131.         WriteLn('Windows demonstration.');
  132.         WriteLn;
  133.         FOR k := 1 TO 22 DO
  134.             Write(DuplStr('. ',40));
  135.         WITH w1 DO
  136.             BEGIN
  137.                 X1 := 10;  Y1 := 5;
  138.                 X2 := 65;  Y2 := 15;
  139.                 DefaultCrsrHide := TRUE;
  140.                 DefaultCrsrSize := WCrsrDefault;
  141.                 Border := WBorder1;
  142.                 IF ColorDisplay THEN
  143.                     BEGIN
  144.                         DefaultAttr := LightGray + Blue * 16;
  145.                         BorderAttr := LightGray * 16;
  146.                     END
  147.                 ELSE
  148.                     BEGIN
  149.                         DefaultAttr := MonoNormal;
  150.                         BorderAttr := MonoIntense;
  151.                     END;
  152.                 HdrText := '';  FtrText := '';
  153.                 Flags := WFlagClrOpen + WFlagRestore + WFlagShowBrdr;
  154.               END;
  155.         w2 := w1;
  156.         WITH w2 DO
  157.             BEGIN
  158.                 X1 := 30;  Y1 := 8;
  159.                 X2 := 78;  Y2 := 16;
  160.                 DefaultCrsrHide := FALSE;
  161.                 Border := WBorder2;
  162.                 IF ColorDisplay THEN
  163.                     BEGIN
  164.                         DefaultAttr := Green;
  165.                         BorderAttr := Yellow;
  166.                         HdrAttr := LightGray + Blue * 16;
  167.                         FtrAttr := HdrAttr;
  168.                     END
  169.                 ELSE
  170.                     BEGIN
  171.                         HdrAttr := MonoReverse;
  172.                         FtrAttr := MonoReverse;
  173.                     END;
  174.                 HdrText := 'Window title';
  175.                 FtrText := 'Any message';
  176.                 HdrPos := WJustLeft;
  177.                 FtrPos := WJustRight;
  178.             END;
  179.         w3 := w1;
  180.         WITH w3 DO
  181.             BEGIN
  182.                 X1 := 40;  Y1 := 16;
  183.                 X2 := 60;  Y2 := 21;
  184.                 Border := WBorderV1H2;
  185.             END;
  186.         DefineWindow (1, w1);
  187.         DefineWindow (2, w2);
  188.         DefineWindow (3, w3);
  189.         Delay (3000);
  190.         OpenWindow (1);
  191.         WriteLn ('This example shows how windows can be easily');
  192.         WriteLn ('employed by your application program.');
  193.         WriteLn;
  194.         WriteLn ('This is window number 1 and all text output is');
  195.         WriteLn ('currently directed to this window.');
  196.         WriteLn;
  197.         WaitForKey;
  198.         OpenWindow (2);
  199.         WriteLn ('This is window number 2, which overlaps the');
  200.         WriteLn ('corner of the first window.  Layered windows');
  201.         WriteLn ('can be built like this, for multiple menu');
  202.         WriteLn ('levels, for example.  Notice how this window');
  203.         WriteLn ('has a header and footer.');
  204.         WriteLn;
  205.         WaitForKey;
  206.         CloseWindow (2);
  207.         ClrScr;
  208.         WriteLn ('Window 2 has now been closed.  Notice how the');
  209.         WriteLn ('original display contents have been restored.');
  210.         WriteLn;
  211.         WriteLn ('It is also possible to have "tiled" windows.');
  212.         WriteLn ('These are windows which do not overlap.');
  213.         WriteLn;
  214.         WaitForKey;
  215.         OpenWindow (3);
  216.         WriteLn ('Window number 3');
  217.         WriteLn;
  218.         WaitForKey;
  219.         SelectWindow (1);
  220.         ClrScr;
  221.         WriteLn ('Output is now being sent to window 1, but');
  222.         WriteLn ('window 3 is still open.  You can switch between');
  223.         WriteLn ('multiple "tiled" windows as you wish.');
  224.         WriteLn;
  225.         WaitForKey;
  226.         ClrScr;
  227.         WriteLn ('A window can also be hidden.');
  228.         WriteLn ('Watch window 3 closely...');
  229.         WriteLn;
  230.         Delay (5000);
  231.         HideWindow (3);
  232.         Delay (2000);
  233.         WriteLn ('It appears that the window has been closed, but its');
  234.         WriteLn ('contents have actually been saved.  A hidden window');
  235.         WriteLn ('can be easily brought back to the display.');
  236.         WriteLn;
  237.         WaitForKey;
  238.         ShowWindow (3);
  239.         Delay (4000);
  240.         CloseWindow (3);
  241.         ClrScr;
  242.         CloseWindow (1);
  243.         OpenWindow (2);
  244.         WriteLn ('It is also possible to move a window around');
  245.         WriteLn ('the screen.  Try pressing the cursor keys to');
  246.         WriteLn ('move this window. Press Escape to quit.');
  247.         WindowCheck := FALSE;
  248.         REPEAT
  249.             ch:=ReadKey;
  250.             CASE ch OF
  251.                 KeyUp:      MoveWindow (2, WMoveUp);
  252.                 KeyDown:    MoveWindow (2, WMoveDown);
  253.                 KeyLeft:    MoveWindow (2, WMoveLeft);
  254.                 KeyRight:   MoveWindow (2, WMoveRight);
  255.             END;
  256.         UNTIL ch=ESC;
  257.         CloseWindow (2);
  258.         PurgeWindow(1);
  259.         PurgeWindow(2);
  260.         PurgeWindow(3);
  261.     END;  { ExOpt3 }
  262.  
  263.  
  264. PROCEDURE ExOpt4;
  265.  
  266.     VAR
  267.         H:  HelpConfiguration;
  268.  
  269.     BEGIN
  270.         WITH H DO
  271.             BEGIN
  272.                 WindowID := 100;
  273.                 HelpFileName := 'EXAMPLE.HLP';
  274.                 X1 := 10;  Y1 := 11;
  275.                 X2 := 62;  Y2 := 20;
  276.                 IF ColorDisplay THEN
  277.                     BEGIN
  278.                         NormalAttr := Green;
  279.                         IndexAttr := LightGray;
  280.                         SelectAttr := LightGray + Blue * 16;
  281.                         BorderAttr := LightGray + Blue * 16;
  282.                         HdrAttr := BorderAttr;
  283.                         FtrAttr := BorderAttr;
  284.                     END
  285.                 ELSE
  286.                     BEGIN
  287.                         NormalAttr := MonoNormal;
  288.                         IndexAttr := MonoIntense;
  289.                         SelectAttr := MonoReverse;
  290.                         BorderAttr := MonoIntense;
  291.                         HdrAttr := MonoReverse;
  292.                         FtrAttr := MonoReverse;
  293.                     END;
  294.                 Border := WBorder1;
  295.                 HdrText := 'Example help: ';
  296.                 FtrText := '';
  297.                 HdrPos := WJustLeft;
  298.                 FtrPos := WJustRight;
  299.                 GeneralKey := KeyF1;
  300.                 ContextKey := NUL;
  301.                 LastHelpKey := KeyF2;
  302.                 MoveWindowKey := HMoveScroll;
  303.                 Flags := HFlagTitle + HFlagPageInd;
  304.             END;
  305.         ClrScr;
  306.         WriteLn ('This example shows how the help system operates.');
  307.         WriteLn ('The file EXAMPLE.HLP should be in the current ');
  308.         WriteLn ('directory.');
  309.         WriteLn;
  310.         Delay(4000);
  311.         HelpInitialize(H);
  312.         WriteLn('Press F1 to display the help index, then select topics.');
  313.         WriteLn('After leaving the help system, F2 will return you to');
  314.         WriteLn('the last help screen you read. ');
  315.         WriteLn;
  316.         WriteLn('If you turn on scroll lock, the cursor keys allow you to');
  317.         WriteLn('move the help window around the screen.  Turning off');
  318.         WriteLn('scroll lock fixes the help window in its new position.');
  319.         WriteLn;
  320.         WriteLn('To quit this example, exit the help system and press F10.');
  321.         WriteLn;
  322.         WriteLn('Awaiting your request for help...');
  323.         REPEAT
  324.         UNTIL ReadKey=KeyF10;
  325.         HelpReset;
  326.     END; { ExOpt4 }
  327.  
  328.  
  329. BEGIN  { ExEnhCon }
  330.     WriteLn('EXENHCON - ENHCON UNIT EXAMPLE PROGRAM');
  331.     WriteLn;
  332.     REPEAT
  333.         ClrScr;
  334.         WriteLn('EXENHCON');
  335.         WriteLn;
  336.         WriteLn('Select the features you wish to try:');
  337.         WriteLn;
  338.         WriteLn('    1.  String editing.');
  339.         WriteLn('    2.  Number editing.');
  340.         WriteLn('    3.  Windowing.');
  341.         WriteLn('    4.  Help system.');
  342.         WriteLn;
  343.         Write('Enter option or zero to quit : ');
  344.         ReadLn(s);
  345.         s:=TrimL(s);
  346.         WriteLn;
  347.         CASE s[1] OF
  348.             '1':    ExOpt1;
  349.             '2':    ExOpt2;
  350.             '3':    ExOpt3;
  351.             '4':    ExOpt4;
  352.         END;
  353.     UNTIL s[1]='0';
  354. END.
  355.  
  356.