home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug175.arc
/
JRTMAN3.LBR
/
JRTMAN.1Z5
/
JRTMAN.105
Wrap
Text File
|
1979-12-31
|
24KB
|
758 lines
.OP
JRT Pascal User's Guide version 3.0 NOT FOR SALE -156-
15. CRT Formatting
This section describes JRT Pascal CRT formatting facilities. It
requries a basic knowledge of Pascal and of JRT Pascal external
procedures.
The CRTMAP utility enables the user to quickly format a CRT
terminal screen. One record at a time may be displayed.
The utility program takes as its input a Map Description File
(MDF) which describes the CRT map in a simple command language. The
utility generates the source program for a Pascal external procedure
which may then be compiled. This external procedure contains all the
logic to display all or part of one record data type. Descriptive
information may also be displayed on the screen.
Source code for CRTMAP is include and its features may be modified or
extended. The distribution version of CRTMAP assumes a Televideo
display terminal. It may be adapted to any other terminal or
computer by modifying two lines in the program. These two lines
specify the control codes for cursor positioning and clearing the
screen. Consult your display terminal user manual for the codes for
your system. The cursor positioning code is in procedure GOTOXY in
the CRTMAP.PAS file. The screen clear code is procedure CLEAR.
Procedure PART2 from CRTMAP.PAS is reproduced here. This code
generates "part2" of the generated external procedure. The line
marked XXX contains the terminal codes for clearing the CRT screen.
The line marked YYY contains the terminal codes for moving the cursor
to a particular position.
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -157-
procedure part2;
begin
writeln(f2; 'procedure clear;');
writeln(f2; 'begin');
writeln(f2; 'write(chr(27),''*'');'); { XXX }
writeln(f2; 'end;');
writeln(f2);
writeln(f2; 'procedure gotoxy (x,y : integer );');
writeln(f2; 'begin');
writeln(f2; 'write(chr(27),''='',chr(y+20h),chr(x+20h));'); { YYY }
writeln(f2; 'end;');
writeln(f2);
end; {part2}
The CRT screen corrdinates have the origin 0,0 in the
upper left corner:
0 x 79
----------------------------------
0 ! !
! !
! !
y ! !
! !
! !
23 ! !
----------------------------------
The first coordinate X indicates the column, the second
Y indicates the row.
15.1 Structure of the external procedure
CRTMAP generates a Pascal external procedure according to the
parameters in the Map Description File. This external procedure then
does the display formatting of your data record.
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -158-
Structure of the generated external procedure:
PART1 EXTERN
TYPE
%INCLUDE type_declaration_filename
PROCEDURE exproc_name
( VAR R : type_name );
PART2 PROCEDURE CLEAR;
PROCEDURE GOTOXY;
PART3 PROCEDURE DISPLAY; { format the CRT }
PART4..PART8 (omitted)
PART9 BEGIN
main_line_code
END;.
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -159-
15.2 Map Definition File
The MDF defines the format of the CRT screen for the display of
one record type. CRTMAP recognizes seven different MDF commands.
The MDF commands MUST be entered in a fixed sequence except for
LITERAL and FIELD which may be intermixed. There should be one
command per line. Blank lines may be inserted for readability.
EXPROC = eeeeeeee
INCLUDE = iiiiiiii
RECORD = rrrrrrrr
any number of intermixed LITERAL and FIELD commands
CURSOR = x,y
END
MDF Commands
EXPROC - the name of the external procedure to be generated by
CRTMAP.
INCLUDE - the name of the %INCLUDE file which contains the TYPE
declaration of the record to be displayed and all TYPEs and
CONSTants to which it refers.
example:
INCLUDE = TYPES.DCL
RECORD - the name of the record data type to be displayed - this type
declaration is in the include file.
LITERAL - causes a character string to be displayed on the CRT
screen, the string must be entered between single quotes.
LITERAL column, row, 'literal string to be displayed'
examples:
LITERAL 0,0,'* this is the upper left corner'
LITERAL 40,12,'* this is about the center'
LITERAL 0,23,'bottom row of the crt'
screen coordinates have the origin 0,0 in the upper left
corner, first number X is the column, second number Y is the
row.
FIELD - causes a field in the input record to be displayed at the
specified location, may include optional minimum width and
decimal places numbers for displaying integers and reals.
FIELD column, row, field_name {:min_width {:dec_places}}
FIELD 10,20, customer_name
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -160-
FIELD 12,20, account_balance:10:2
FIELD 20,60, days_until_armageddon:1
CURSOR - specifies where the cursor should be positioned on the
screen after the record is displayed.
CURSOR column, row
END - indicates end of Map Description File, ALWAYS required.
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -161-
15.3 Operating CRTMAP
To operate CRTMAP, first prepare the Map Description File
(section 15.2). Prepare a file containing the record to be displayed
and its subordinate type declarations - this will be the INCLUDE
file.
Make sure the CRTMAP utility was modified to support your
terminal type (see section 15.).
To run the utility, enter:
EXEC CRTMAP
It will ask for the "filename.type" of your Map Description
File.
On successful termination of CRTMAP, the new external procedure
source file will be found on the default disk. It must be compiled
with the JRT Pascal version 3 compiler.
15.4 CRTMAP example
An example of the use of the CRTMAP utility is provided here. A
simple customer record is formatted and displayed. The Map
Definition File named MDF is listed. The include file named
CUSTOMER.PAS contains the main record declaration CUST and a
subordinate declaration CHAR30.
The external procedure generated by CRTMAP is named CUSTMAP.PAS
and is listed.
A complete compiler listing of CRTMAP.PAS follows.
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -162-
Operation flowchart of CRTMAP utility (ver 3.0)
Map
Description
File
!
!
!
!
V
-----------------
! !
! CRTMAP !
! utiltiy !
! !
-----------------
!
!
!
V
Pascal source
code external %include
procedure file
! /
! /
! /
! /
! /
! /
! /
! /
! /
V V
-----------------
! !
! JRTPAS3 !
! !
-----------------
!
!
!
!
V
compiled
CRT mapping
external
procedure
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -163-
CRT Screen formatted by CUSTMAP external procedure
-----------------------------------------------------------------
! !
! ---------- CUSTOMER RECORD ---------- !
! !
! !
! Name PASCAL, BLAISE !
! !
! Addr 777 RUE D'ARGENT !
! !
! City PARIS !
! !
! !
! !
! !
! Balance $ 1490.34 !
! !
! !
! !
! !
! _ !
! !_! !
!_______________________________________________________________!
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -164-
File CUSTOMER.PAS
contains TYPE declaration of customer data record
CHAR30 = ARRAY [1..30] OF CHAR;
CUST = RECORD
NAME : CHAR30;
ADDRESS : CHAR30;
CITY : CHAR30;
BALANCE : REAL;
END;
FILE MDF
contains Map Definition File which describes CRT screen format
EXPROC = CUSTMAP
INCLUDE = CUSTOMER.PAS
RECORD = CUST
LITERAL = 0,0,'---------- CUSTOMER RECORD ----------'
LITERAL = 5,3,'Name '
FIELD =12,3,NAME
LITERAL = 5,5,'Addr '
FIELD = 12,5,ADDRESS
LITERAL = 5,7,'City '
FIELD = 12,7,CITY
LITERAL = 15,14,'Balance $'
FIELD = 15,14,BALANCE:8:2
CURSOR = 0,22
END
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -165-
File CUSTMAP.PAS
Pascal external procedure generated by CRTMAP utility
{ CRTMAP generated external procedure }
extern
type
%include ('CUSTOMER.PAS ')
procedure CUSTMAP ( var r : CUST );
procedure clear;
begin
write(chr(27),'*');
end;
procedure gotoxy ( x,y : integer );
begin
write(chr(27),'=',chr(y+20h),chr(x+20h));
end;
procedure display;
begin
clear;
gotoxy( 0 ,0 );
write('---------- CUSTOMER RECORD ----------');
gotoxy( 5 ,3 );
write('Name ');
gotoxy( 12 ,3 );
write( r,NAME );
gotoxy( 5 ,5 );
write('Addr ');
gotoxy( 12 ,5 );
write( r,ADDRESS );
gotoxy( 5 ,7 );
write('City ');
gotoxy( 12 ,7 );
write( r,CITY );
gotoxy( 5 ,14 );
write('Balance $');
gotoxy( 15 ,14 );
write( r,BALANCE:8:2 );
gotoxy( 0 ,22 );
end;
begin
display;
end;.
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè JRT Pascal User's Guide version 3.0 NOT FOR SALE -166-
JRT Pascal ver 3.0 CRTMAP Page 001
----- CRT Mapping Utility -----
0000 0002: %page(50)
0000 0003:
0000 0004: { This version setup for Televideo terminals. To adapt to oth
0000 0005: terminals modify PROCEDURE PART2 which generates the cursor
0000 0006: positioning (gotoxy) and clear screen (clear) codes. }
0000 0007:
0000 0008: program crtmap;
0000 0009:
0003 0010: type
0010 0011: char16 = array [1..16] of char;
0010 0012:
0010 0013: var
0010 0014: ch : char;
0010 0015: alphameric : set of char;
0010 0016: end_of_file : boolean;
0010 0017: map_file_name : string[15];
0010 0018: word : char16;
0010 0019: exproc_name : char16;
0010 0020: include_name : char16;
0010 0021: record_name : char16;
0010 0022: f1, f2 : file of char;
0010 0023:
0010 0024:
0010 0025: procedure error ( msg : string[40] );
0013 0026: var
0013 0027: dummy : char16;
0016 0028: begin
001A 0029: writeln;
001E 0030: writeln;
0028 0031: writeln(msg);
002C 0032: writeln;
002C 0033: { abnormally terminate - return to CP/M }
0034 0034: call(0,dummy,dummy);
0035 0035: end;
0035 0036:
0035 0037: procedure get_char;
003B 0038: begin
004C 0039: read(f1; ch);
0081 0040: if ch = chr(1ah) then error('Premature end of input file');
008D 0041: write(ch);
008E 0042: end;
008E 0043:
008E 0044: procedure get_word;
0091 0045: label 99;
0091 0047: var
0091 0047: i : integer;
0094 0048: begin
009D 0049: word := ' ';
00AC 0050: while not (ch in alphameric) do
00AC 0051: begin
.PAè
JRT Pascal User's Guide version 3.0 NOT FOR SALE -167-
JRT Pascal ver 3.0 CRTMAP page 002
----- CRT Mapping Utility -----
00B1 0052: get_char;
00B4 0053: end;
00C4 0054: word[1] := ch;
00C9 0055: i := 2;
00CE 0056: get_char;
00DC 0057: while (ch in alphameric) do
00DC 0058: begin
00EF 0059: word[i] := ch;
00F9 0060: i := i + 1;
00FE 0061: get_char;
0101 0062: end;
010E 0063: word := upcase(word);
010F 0064: end; {get_word}
010F 0065:
010F 0066:
010F 0067: procedure init;
0115 0068: begin
012C 0069: writeln('CRTMAP ver 3.0');
0130 0070: writeln;
0157 0071: write('name of Map Desription File : ');
0160 0072: readln(map_file_name);
0164 0073: writeln;
0168 0074: writeln;
0177 0075: reset(f1,map_file_name,binary,256);
017C 0076: end_of_file := false;
0185 0077: ch := ' ';
01A7 0078: alphameric := ['A'..'Z','a'..'z','0'..'9',':','.'];
01AC 0079: get_word;
01E1 0080: if word <> 'EXPROC' then error('EXPROC command expected');
01E6 0081: get_word;
01F2 0082: exproc_name := word;
020A 0083: rewrite(f2, exproc_name + '.pas', binary, 256);
020F 0084: get_word;
0246 0085: if word <> 'INCLUDE' then error('INCLUDE' command expected');
024B 0086: get_word;
0257 0087: include_name := word;
025C 0088: get_word;
0291 0089: if word <> 'RECORD' then error('RECORD' command expected');
0296 0090: get_word;
02A2 0091: record_name := word;
02A3 0092: end; {init}
02A3 0093:
02A3 0094:
02A3 0095: procedure part1;
02A9 0096: begin
02DF 0097: writeln(f2; '{CRTMAP generated external procedure }');
02F4 0098: writeln(f2; 'extern');
02FF 0099: writeln(f2);
0312 0100: writeln(f2; 'type');
033C 0101: writeln(f2; '%include (''',include_name,''')');
.PAè JRT Pascal User's Guide version 3.0 NOT FOR SALE -168-
JRT Pascal ver 3.0 CRTMAP page 003
----- CRT Mapping Utility -----
0347 0102: writeln(f2);
0386 0103: writeln(f2; 'procedure ',exproc_name, '(var r : '.recor_nam
');');
0391 0104: writeln(f2);
0392 0105: end; {part1}
0392 0106:
0392 0107:
0392 0108: procedure part2;
0398 0109: begin
03B7 0110: writeln(f2; 'procedure clear;');
03CB 0111: writeln(f2; 'begin');
03ED 0112: writeln(f2; 'write(chr(27),''*'');');
0400 0113: writeln(f2; 'end;');
040B 0114: writeln(f2);
043D 0115: writeln(f2; 'procedure gotoxy ( x,y : integer );');
0451 0116: writeln(f2; 'begin');
0489 0117: writeln(f2; 'write(chr(27),''='',chr(y+20h),chr(x+20h));');
049C 0118: writeln(f2; 'end;');
04A7 0119: writeln(f2);
04A8 0120: end; {part2}
04A8 0121:
04A8 0122:
04A8 0123: procedure part3; {create DISPLAY procedure}
04A8 0124:
04AB 0125: procedure process_coordinates;
04AE 0126: var
04AE 0127: x_coord, y_coord : char16;
04B1 0128: begin
04B6 0129: get_word;
04C2 0130: x_coord := word;
04C7 0131: get_word;
04D3 0132: y_coord := word;
0507 0133: writeln(f2; 'gotoxy( ',x_coord,',',y_coord,');');
0508 0134: end;
0508 0135:
0508 0136: procedure process_string;
050E 0137: begin
050E 0138: {find start of string}
052E 0139: while not (ch in ['''',chr(0dh),' ',chr(9),chr(1ah)]) do
0536 0140: get_char;
0566 0141: if ch <> '''' then error('Literal string expected');
057B 0142: write(f2; 'write(');
057B 0143: repeat
058E 0144: write(f2; ch);
0593 0145: get_char;
05A1 0146: until ch = chr(0dh);
05B2 0147: writeln(f2; ');');
05B3 0148: end;
05B3 0149:
05B3 0150:
05B6 0151: begin {part3}
.PAè JRT Pascal User's Guide version 3.0 NOT FOR SALE -169-
JRT Pascal ver 3.0 CRTMAP page 004
----- CRT Mapping Utility -----
05D7 0152: writeln(f2; 'procedure display;');
05EB 0153: writeln(f2; 'begin');
0600 0154: writeln(f2; 'clear;');
0608 0155: while not end_of_file do
0608 0156: begin
060D 0157: get_word;
0613 0158: case word of
0621 0159: 'LITERAL' :
0621 0160: begin
0626 0161: process_coordinates;
062B 0162: process_string;
062E 0163: end;
063A 0164: 'FIELD' :
063A 0165: begin
063F 0166: process_coordinates;
0644 0167: get_word;
066C 0168: writeln(f2; 'write( r,',word,');');
066F 0169: end;
0684 0170: 'CURSOR' : process_coordinates;
0696 0171: 'END' : end_of_file := true;
06D3 0172: else : error('LITERAL, FIELD, CURSOR, or END command ex
cted');
06D4 0173: end;
06D7 0174: end;
06EA 0175: writeln(f2; 'end;' );
06F5 0176: writeln(f2);
06F6 0177: end; {part3}
06F6 0178:
06F6 0179:
06F6 0180: procedure part9;
06FC 0181: begin
0710 0182: writeln(f2; 'begin');
0727 0183: writeln(f2; 'display;');
073B 0184: writeln(f2; 'end;.');
073C 0185: end; {part9}
073C 0186:
073C 0187:
073F 0188: begin {crtmap}
0744 0189: init;
0749 0190: part1;
074E 0191: part2;
0753 0192: part3;
0758 0193: part9;
075C 0194: close(f1);
0760 0195: close(f2);
0761 0196: end {crtmap}.
No errors detected
Module size = 1893 dec bytes
End of compile for CRTMAP
Copy compliments of Merle Schnick SECTION 15: CRT Formatting
.PAè