home *** CD-ROM | disk | FTP | other *** search
- program CRT;
- {CRT.PAS Turbo Pascal 3.0 CRT Characteristics Display Utility
-
- V01 L00 original CompuServe Borland SIG edition created on 85-05-22 by
- Dennis E. Hamilton for demonstrating the use of the extra
- CRT interfaces made available in T3CRT.PLB.
-
- Turbo Pascal support for CRT display devices allows programs to obtain
- standard operations such as ClrScr, GotoXY, and LowVideo without having
- to incorporate hardware-dependent information. That is because the
- same terminal configuration already installed into the production copy
- of the compiler is automatically incorporated into compiled programs.
-
- The file T3CRT.PLB defines additional interfaces beside the standard
- built-in ones. These interfaces allow a compiled program to INSPECT
- its terminal configuration and adjust its behavior accordingly. This
- lets generic programs be designed to accomodate the one weakness of the
- basic Turbo Pascal scheme: Not all built-in operations are operational
- for all terminal configurations. By accessing the auxilliary T3CRT.PLB
- information, a generic program can adapt itself to use of those display
- features which are actually available. In this way, full use of the
- equipment is obtained without requiring custom installation.
-
- CRT.PAS simply provides a capability report about the terminal display
- configuration that carried over from its compilation. This is offered
- as an example of T3CRT.PLB usage. For more details, it is useful to
- review the T3CRT.PLB file and the additional information supplied in
- file T3CRT.HLP. (Current versions of all of these files can be found
- on the CompuServe CP-MIG and Borland International SIG databases.) }
-
-
- {$I T3CRT.PLB } {Vintage #1.00 or later}
- {...
- ... }
- type
-
- CrtCtlString = string[20]
- {Typical string for a Crt control sequence};
-
- var
-
- clock: integer
- {clock rate specified for this system};
-
- procedure
-
- CrtClr;
-
- var i: integer {counter};
- begin {Procedure to clear the display the best way available, and then
- position to the top line if it can be reached.}
- if length(CrtClrStr) = 0
- then begin
- for i := 1 to CrtRows
- do CrtLn;
- {Scrolling the display full of blank lines}
- if length(CrtGotoStr) > 0 then GotoXY(1,1);
- {Homing if there is any way to do it}
- end
- else ClrScr;
- {Using the direct approach when it is installed}
- end {CrtClr};
-
-
- procedure
-
- space(n: integer);
-
- begin {skip n columns}
- for n := n downto 1
- do CrtOut(' ');
- end;
-
-
- procedure
-
- NotImplemented;
-
- begin {Describe a non-implemented display function}
- write('not implemented');
- {Note assumption that OUTPUT is assigned to CrtOut's device}
- end;
- {...
- ... }
- procedure
-
- CharName(ch: integer {ord of a character});
-
- const {names of the ASCII control characters}
-
- cn1: string[34] = 'dnsseeeabbhlvfcssdddddnsecesefgrus';
- cn2: string[34] = 'euottoncestftfroilccccaytamusssssp';
- cn3: string[34] = 'llhxxtqkl e1234knbn bc ';
-
- begin {Describe a character code by its ASCII name/graphic}
-
- if ch = 127 then ch := -1
- {folding DEL code to front with the other controls};
-
- if ch > 125
- then begin LowVideo; write('#', ch); end
- {handling tilde and 8-bit values by their decimal numeric codes}
- else if ch > 32
- then begin NormVideo; CrtOut(chr(ch)); end
- {directly showing the character for safe, plain ascii codes}
- else begin
- LowVideo;
- ch := ch+2;
- CrtOut(cn1[ch]);
- CrtOut(cn2[ch]);
- ch := ord(cn3[ch]);
- if ch <> ord(' ') then CrtOut(chr(ch));
- end;
- {giving the standard acronym for the character}
- NormVideo;
- end {CharName};
-
-
-
- procedure
-
- SequenceName(st: CrtCtlString);
-
- var i: integer {counter};
-
- begin {Presenting the CharNames for each in a control sequence}
- for i := 1 to length(st)
- do begin
- if i>1 then CrtOut(' ');
- {being careful to separate a CharName from its predecessor}
- CharName(ord(st[i]));
- end;
- end {Sequence Name};
- {...
- ... }
- procedure
-
- DelayAmount(d: integer);
-
- begin {describe unsigned millisecond delay amount}
- write(' -- followed by ');
- if d >= 0
- then write(d)
- else write(65536.0+d:0:0);
- write('ms delay');
- end;
-
-
- procedure
-
- DescribeSequence(st: CrtCtlString;
- d: integer);
-
- begin {Describe the specified string with its delay}
- if length(st) = 0
- then NotImplemented
- else begin
- SequenceName(st);
- if d <> 0
- then DelayAmount(d);
- end;
- end {DescribeSequence};
-
-
- procedure
-
- BailOut(n: integer;
- p: integer);
- begin {Error procedure for correct release of terminal on quit.}
- CrtExit;
- if n = 1 then halt;
- {exit without error report if CTRL-C User-Break encountered}
- end;
- {...
- ... }
-
- BEGIN
- CrtInit;
- {Insuring that any initialization requirements are satisfied.}
- ErrorPtr := Addr(BailOut);
- {Guaranteeing that cleanup is done even if the program terminates
- because of a run-time or input-output error.}
-
- CrtClr;
- writeln('CRT> #1.00 85-05-22 TURBO PASCAL CRT-CONFIGURATION PARAMETERS');
- {Telling the folks who we are}
-
- CrtLn;
-
- {Identify the overall terminal configuration:}
- begin
- clock := CrtClockMHz mod 32;
- if clock = 0 then clock := 32;
- space(5);
- LowVideo; write(clock, 'MHz');
- NormVideo; write(' Z80 COMPUTER WITH ');
- LowVideo; write(CrtRows, '-by-', CrtColumns);
- NormVideo; write(' ');
- LowVideo; write(CrtType);
- NormVideo; writeln(' DISPLAY');
- end;
-
- CrtLn;
-
- {Show the initialization and termination sequences:}
- begin
- space(5);
- write(' CrtInit: ');
- DescribeSequence(CrtInitStr, CrtCtlDelay);
- CrtLn;
-
- space(5);
- write(' CrtExit: ');
- DescribeSequence(CrtExitStr, CrtCtlDelay);
- CrtLn;
- end;
-
- CrtLn;
- {...
- ... }
-
- {Show the home and GotoXY-sequence information:}
- begin
- space(5);
- write(' CrtHome: ');
- DescribeSequence(CrtHomeStr, CrtCtlDelay);
- CrtLn;
-
- CrtLn;
-
- space(5);
- write(' GotoXY: ');
- if length(CrtGotoStr) = 0
- then NotImplemented
- else begin
- SequenceName(CrtGotoStr);
- DelayAmount(CrtGotoDelay);
- Crtln;
- space(15);
- write('column number (X-1)+', CrtColAdjust,
- ' goes to position ', CrtColPlace,
- ' in ');
- if CrtRadix = CrtDecimal
- then writeln('decimal,')
- else writeln('binary,');
- space(15);
- write(' row number (Y-1)+', CrtRowAdjust,
- ' goes to position ', CrtRowPlace, '.');
- end;
- CrtLn;
- end;
-
- CrtLn;
-
- {...
- ... }
- {Describe the other editing operations also:}
- begin
- space(5); write(' ClrScr: ');
- if length(CrtClrStr) = 0
- then if length(CrtHomeStr) <> 0
- then write('implemented in CrtHome sequence!?')
- else NotImplemented
- else begin
- if length(CrtHomeStr) <> 0
- then write('CrtHome plus ');
- DescribeSequence(CrtClrStr, CrtClrDelay);
- end;
- CrtLn;
- space(5); write(' ClrEol: ');
- DescribeSequence(CrtEolStr, CrtCtlDelay);
- CrtLn;
- space(5); write(' DelLine: ');
- DescribeSequence(CrtDelStr, CrtClrDelay);
- CrtLn;
- space(5); write(' InsLine: ');
- DescribeSequence(CrtInsStr, CrtClrDelay);
- CrtLn;
- end;
-
- CrtLn;
-
- {Describe the mode strings:}
- begin
- write(' NormVideo: ');
- DescribeSequence(CrtNormStr, CrtCtlDelay);
- CrtLn;
-
- space(5); write('LowVideo: ');
- DescribeSequence(CrtAltStr, CrtCtlDelay);
- CrtLn;
- end;
-
- CrtLn;
- CrtExit;
- {Releasing the terminal to its non-application configuration,
- in case there is any difference.}
- END.