home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
pascal
/
tplib21.zip
/
INSTALL.EXE
/
EXENHCON.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
12KB
|
356 lines
(* Example program: ENHCON unit *)
PROGRAM EXENHCON;
USES
STRINGS,CRT,ENHCON;
VAR
s: STRING;
PROCEDURE ExOpt1;
VAR
ExFormat: EditFormatRec;
s: STRING;
ch: CHAR;
BEGIN
WITH ExFormat DO
BEGIN
IF ColorDisplay THEN
Attribute := LightGray + Blue * 16
ELSE
Attribute := MonoReverse;
StartChar := NUL;
EndChar := NUL;
MarkerAttr := 0;
AllowChars := StandardChars;
ExitKeys := [CR, KeyF10];
EditKey := NUL;
RestoreKey := ESC;
AbortKey := ESC;
Flags := EdFlagInsStat + EdFlagFirstClr + EdFlagHideCrsr;
END;
CursorInsert := TRUE;
ClrScr;
WriteLn('Enter a new string or edit the existing one, then press');
WriteLn('RETURN or F10 to complete the edit. Notice how the code');
WriteLn('returned by EditString indicates which key was pressed.');
WriteLn('You can use the Escape key to abandon changes or to abort');
WriteLn('the edit. In this example, aborting the edit will return');
WriteLn('you to the example menu.');
s := 'This is the initial string';
REPEAT
GotoXY(20,14);
ch:=EditString (ExFormat, s, 30);
GotoXY(20,20);
Write('Returned character code = ', HexStr(Ord(ch),2), ' hex.');
Delay(3000);
GotoXY(20,20);
ClrEOL;
UNTIL ch = ESC;
END; { ExOpt1 }
PROCEDURE ExOpt2;
VAR
i: LongInt;
ch: CHAR;
ExFormat: EditFormatRec;
BEGIN
WITH ExFormat DO
BEGIN
Attribute := 0;
StartChar := #16;
EndChar := #17;
IF ColorDisplay THEN
MarkerAttr := LightRed
ELSE
MarkerAttr := MonoIntense;
ExitKeys := [CR, KeyF10];
EditKey := NUL;
RestoreKey := ESC;
AbortKey := ESC;
NumFormat := '$PC12:2';
SignalError := StdSignalError;
Flags := EdFlagInsStat + EdFlagFirstClr + EdFlagHideCrsr;
END;
CursorInsert := TRUE;
ClrScr;
WriteLn('This example shows how EditInt can be used with a');
WriteLn('typical application - Amounts of money.');
WriteLn('As with the previous example, use RETURN or F10 to complete');
WriteLn('the edit. You can use the Escape key to abandon changes');
WriteLn('or return to the menu, as before. The amount of money is ');
WriteLn('represented as a LongInt variable, and two assumed decimal');
WriteLn('places are used. The minimum and maximum allowable values');
WriteLn('are plus and minus $5,000.');
i := 100;
REPEAT
GotoXY(20,14);
ch:=EditInt (ExFormat, i, -500000, 500000);
GotoXY(20,20);
WriteLn('Returned code = ', HexStr(Ord(ch),2), ' hex.');
GotoXY(20,22);
WriteLn('Value of integer is now ', i:8);
Delay(6000);
GotoXY(20,20);
ClrEOL;
GotoXY (20,22);
ClrEOL;
UNTIL ch=ESC;
END; { ExOpt2 }
PROCEDURE ExOpt3;
VAR
w1, w2, w3: WindowDefinition;
k: BYTE;
ch: CHAR;
PROCEDURE WaitForKey;
VAR
ch: CHAR;
BEGIN
WriteWindow ('Press any key...');
ch := ReadKey;
WriteWindow (' ');
END;
BEGIN
CheckBreak := FALSE;
ClrScr;
WriteLn('Windows demonstration.');
WriteLn;
FOR k := 1 TO 22 DO
Write(DuplStr('. ',40));
WITH w1 DO
BEGIN
X1 := 10; Y1 := 5;
X2 := 65; Y2 := 15;
DefaultCrsrHide := TRUE;
DefaultCrsrSize := WCrsrDefault;
Border := WBorder1;
IF ColorDisplay THEN
BEGIN
DefaultAttr := LightGray + Blue * 16;
BorderAttr := LightGray * 16;
END
ELSE
BEGIN
DefaultAttr := MonoNormal;
BorderAttr := MonoIntense;
END;
HdrText := ''; FtrText := '';
Flags := WFlagClrOpen + WFlagRestore + WFlagShowBrdr;
END;
w2 := w1;
WITH w2 DO
BEGIN
X1 := 30; Y1 := 8;
X2 := 78; Y2 := 16;
DefaultCrsrHide := FALSE;
Border := WBorder2;
IF ColorDisplay THEN
BEGIN
DefaultAttr := Green;
BorderAttr := Yellow;
HdrAttr := LightGray + Blue * 16;
FtrAttr := HdrAttr;
END
ELSE
BEGIN
HdrAttr := MonoReverse;
FtrAttr := MonoReverse;
END;
HdrText := 'Window title';
FtrText := 'Any message';
HdrPos := WJustLeft;
FtrPos := WJustRight;
END;
w3 := w1;
WITH w3 DO
BEGIN
X1 := 40; Y1 := 16;
X2 := 60; Y2 := 21;
Border := WBorderV1H2;
END;
DefineWindow (1, w1);
DefineWindow (2, w2);
DefineWindow (3, w3);
Delay (3000);
OpenWindow (1);
WriteLn ('This example shows how windows can be easily');
WriteLn ('employed by your application program.');
WriteLn;
WriteLn ('This is window number 1 and all text output is');
WriteLn ('currently directed to this window.');
WriteLn;
WaitForKey;
OpenWindow (2);
WriteLn ('This is window number 2, which overlaps the');
WriteLn ('corner of the first window. Layered windows');
WriteLn ('can be built like this, for multiple menu');
WriteLn ('levels, for example. Notice how this window');
WriteLn ('has a header and footer.');
WriteLn;
WaitForKey;
CloseWindow (2);
ClrScr;
WriteLn ('Window 2 has now been closed. Notice how the');
WriteLn ('original display contents have been restored.');
WriteLn;
WriteLn ('It is also possible to have "tiled" windows.');
WriteLn ('These are windows which do not overlap.');
WriteLn;
WaitForKey;
OpenWindow (3);
WriteLn ('Window number 3');
WriteLn;
WaitForKey;
SelectWindow (1);
ClrScr;
WriteLn ('Output is now being sent to window 1, but');
WriteLn ('window 3 is still open. You can switch between');
WriteLn ('multiple "tiled" windows as you wish.');
WriteLn;
WaitForKey;
ClrScr;
WriteLn ('A window can also be hidden.');
WriteLn ('Watch window 3 closely...');
WriteLn;
Delay (5000);
HideWindow (3);
Delay (2000);
WriteLn ('It appears that the window has been closed, but its');
WriteLn ('contents have actually been saved. A hidden window');
WriteLn ('can be easily brought back to the display.');
WriteLn;
WaitForKey;
ShowWindow (3);
Delay (4000);
CloseWindow (3);
ClrScr;
CloseWindow (1);
OpenWindow (2);
WriteLn ('It is also possible to move a window around');
WriteLn ('the screen. Try pressing the cursor keys to');
WriteLn ('move this window. Press Escape to quit.');
WindowCheck := FALSE;
REPEAT
ch:=ReadKey;
CASE ch OF
KeyUp: MoveWindow (2, WMoveUp);
KeyDown: MoveWindow (2, WMoveDown);
KeyLeft: MoveWindow (2, WMoveLeft);
KeyRight: MoveWindow (2, WMoveRight);
END;
UNTIL ch=ESC;
CloseWindow (2);
PurgeWindow(1);
PurgeWindow(2);
PurgeWindow(3);
END; { ExOpt3 }
PROCEDURE ExOpt4;
VAR
H: HelpConfiguration;
BEGIN
WITH H DO
BEGIN
WindowID := 100;
HelpFileName := 'EXAMPLE.HLP';
X1 := 10; Y1 := 11;
X2 := 62; Y2 := 20;
IF ColorDisplay THEN
BEGIN
NormalAttr := Green;
IndexAttr := LightGray;
SelectAttr := LightGray + Blue * 16;
BorderAttr := LightGray + Blue * 16;
HdrAttr := BorderAttr;
FtrAttr := BorderAttr;
END
ELSE
BEGIN
NormalAttr := MonoNormal;
IndexAttr := MonoIntense;
SelectAttr := MonoReverse;
BorderAttr := MonoIntense;
HdrAttr := MonoReverse;
FtrAttr := MonoReverse;
END;
Border := WBorder1;
HdrText := 'Example help: ';
FtrText := '';
HdrPos := WJustLeft;
FtrPos := WJustRight;
GeneralKey := KeyF1;
ContextKey := NUL;
LastHelpKey := KeyF2;
MoveWindowKey := HMoveScroll;
Flags := HFlagTitle + HFlagPageInd;
END;
ClrScr;
WriteLn ('This example shows how the help system operates.');
WriteLn ('The file EXAMPLE.HLP should be in the current ');
WriteLn ('directory.');
WriteLn;
Delay(4000);
HelpInitialize(H);
WriteLn('Press F1 to display the help index, then select topics.');
WriteLn('After leaving the help system, F2 will return you to');
WriteLn('the last help screen you read. ');
WriteLn;
WriteLn('If you turn on scroll lock, the cursor keys allow you to');
WriteLn('move the help window around the screen. Turning off');
WriteLn('scroll lock fixes the help window in its new position.');
WriteLn;
WriteLn('To quit this example, exit the help system and press F10.');
WriteLn;
WriteLn('Awaiting your request for help...');
REPEAT
UNTIL ReadKey=KeyF10;
HelpReset;
END; { ExOpt4 }
BEGIN { ExEnhCon }
WriteLn('EXENHCON - ENHCON UNIT EXAMPLE PROGRAM');
WriteLn;
REPEAT
ClrScr;
WriteLn('EXENHCON');
WriteLn;
WriteLn('Select the features you wish to try:');
WriteLn;
WriteLn(' 1. String editing.');
WriteLn(' 2. Number editing.');
WriteLn(' 3. Windowing.');
WriteLn(' 4. Help system.');
WriteLn;
Write('Enter option or zero to quit : ');
ReadLn(s);
s:=TrimL(s);
WriteLn;
CASE s[1] OF
'1': ExOpt1;
'2': ExOpt2;
'3': ExOpt3;
'4': ExOpt4;
END;
UNTIL s[1]='0';
END.