home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug077.arc
/
SIGNS2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
7KB
|
231 lines
program signs;
{kilobaud, Aug '78, page 90
program originally in North Star BASIC by Joseph J. Roehrig
numbers in brackets indicate line numbers in original program
}
{ Modified to work with Turbo pascal by Peter Billing June 1985}
LABEL
1;
CONST
wdth=6; {# letters per line
Each letter requires 12 spaces; an 80 column screen can
accomodate 6 letters (6x12=72). A 132 column printer
can handle 11 letters
The program is now constructed so that changing wdth is the
ONLY thing that is necessary to changing the letter count.}
alphabet = 27; {number of letters supported in alphabet}
{To expand the alphabet several things need to be done:
1. Change "alphabet" appropriately.
2. Alter procedure ucase so it filters correctly.
3. Include new characters in font.dat.
4. Main program line "if 0>c then c := 27;" prohibits
mapping characters into negative values in array L.
It also effectively prohibits any characters whose
ASCII values are less than 64. You are going to
have to redo the logic there to include numbers...}
TYPE
str8 = string [8]; {for reading font.dat}
VAR
fout : text;
V : array[0..31] of integer; {patterns}
LE : array[1..alphabet] of char; {top of array equ number of chars}
L : array[1..alphabet,1..7] of integer; {dimensions of each letter}
Z : array[1..5] of integer; {decoder}
DD : array[1..wdth]of char; {wdth equ total # of letters on a line}
CHA : char;
a,
b,
c,
d,
f,
g,
i,
q,
num,
e : integer;
function ucase(ch:char):char;
{This function filters all non-alphabetical characters, replacing
them with blanks. It also converts all lower case letters to
upper case.}
begin
if (ch in ['A'..'Z']) {or (ch in ['0'..'9'])}
then ucase := ch
{accept upper case [and numbers as is]}
else
if ch in ['a'..'z']
then {translate to upper case}
ucase := chr(ord(ch) - 32)
else ucase := ' ' {filter illegal characters}
end; {ucase}
Procedure Setfont(letter:str8);
{This procedure fills the array L with the font values from
"font.dat". It takes the place of a series of DATA statements
in the original BASIC program.
Additionally, LE is filled from the 8th character in each font value.
This allows LE to grow automatically with alphabet.}
var
{letter : str8;}
a,b : integer;
fin : text; {file of str8;}
{L : array [1..alphabet,1..7] of integer - global
LE : array [1..alphabet] of char - global}
begin
(* assign(fin,'FONT.DAT');
reset(fin); {font.dat contains array values}
if eof(fin)
then writeln('"Font.dat" must be on logged disk.');
for a := 1 to alphabet do {70, set loop value to tot # chars formed}
begin
readln(fin,letter); {'letter' contains 8 char; 1st 7 are significant}
*) for b := 1 to 7 do {8th is the LE label}
begin
L[num,b] := ord(letter[b])-64; {80}
LE[num] := letter[8]; {15}
end; {for b}
(* end; {for a}*)
num:=num+1;
end; {procedure setfont('}
procedure initialize;
{fill arrays DD, Z and V}
begin
for a := 1 to wdth do DD[a] := ' '; {wdth blanks}
z[1] := 10000; z[2] := 1000; z[3] := 100; z[4] := 10; z[5] := 1;
v[0]:=0; v[1]:=1; {50 read binary number line}
v[2]:=10; v[3]:=11; v[4]:=100; v[5]:=101; v[6]:=110; v[7]:=111;
v[8]:=1000; v[9]:=1001; v[10]:=1010; v[11]:=1011; v[12]:= 1100;
v[13]:=1101; v[14]:=1110; v[15]:=1111;
for a := 16 to 31 do v[a] := 10000+v[a-16]; {60}
{there has to be a better way to fill this array, when you
find it, let me know}
end; {procedure initialize}
procedure setdev;
{output direction}
var
choice : char;
filnam : string [14];
begin
writeln;
writeln('Do you wish output to:');
writeln(' 1) printer (lst:)');
writeln(' 2) screen (con:)');
writeln(' 3) a file');
repeat
read(kbd,choice);
until choice in ['1','2','3'];
case choice of
'1': assign(fout,'lst:');
'2': assign(fout,'con:');
'3': begin
write('Name of file: ');
readln(filnam);
assign(fout,filnam);
end;
end; {case}
rewrite(fout)
end; {procedure setdev}
Procedure Data;
begin
setfont('DJQ_QQQA');
setfont('^QQ_QQ^B');
setfont('NQPPPQNC');
setfont('\RQQQR\D');
setfont('_PP^PP_E');
setfont('_PP^PPPF');
setfont('NQPPSQNG');
setfont('QQQ_QQQH');
setfont('NDDDDDNI');
setfont('AAAAQIFJ');
setfont('QRTXTRQK');
setfont('PPPPPP_L');
setfont('Q[UQQQQM');
setfont('QYUUUSQN');
setfont('DJQQQJDO');
setfont('^QQ^PPPP');
setfont('DJQQUJEQ');
setfont('^QQ^TRQR');
setfont('NQPNAQNS');
setfont('_DDDDDDT');
setfont('QQQQQQNU');
setfont('QQQQQJDV');
setfont('QQQQU_QW');
setfont('QJJDJJQX');
setfont('QQJDDDDY');
setfont('_ABDDH_Z');
setfont('@@@@@@@@');
end;
begin {main program}
clrscr;
num:=1;
data;
initialize;
writeln(' SSSSSS IIIIII GGGGGG NN NN SSSSSS ');
writeln(' SS SS II GG GG NNNN NN SS SS');
writeln(' SS II GG NN NN NN SS ');
writeln(' SSSSSS II GG NN NN NN SSSSSS ');
writeln(' SS II GG GGGG NN NN NN SS');
writeln(' SS SS II GG GG NN NNNN SS SS');
writeln(' SSSSSS IIIIII GGGGGG NN NN SSSSSS ');
writeln;
writeln;
writeln(' This program will accept upper case');
writeln('characters and blanks. (Lower case letters will translate)');
writeln;
writeln('Enter a period and a carriage return to end.');
writeln('Pick your device: screen, printer or file.');
setdev;
writeln;
while DD[1] <> '.' do
begin {while}
writeln('Enter a period and a carriage return to end.');
Writeln('Input line:');
for a := 1 to wdth do write('_');
writeln;
for i:= 1 to wdth do
begin
read(kbd,DD[i]);write(DD[i]);
if DD[1] = '.'
then goto 1; {sorry, had to GOTO}
end;writeln;
for e := 1 to wdth do
DD[e] := ucase(DD[e]);
{98 "get paper ready & enter <cr>}
for d := 1 to 7 do {105}
begin
for b := 1 to wdth do {110}
begin
c := b; {120}
c := ord(DD[c])-64;
if 0 > c
then c := 27;
f := L[c,d]; {135}
f := v[f]; {136}
q := c; {137}
for e := 1 to 5 do {150}
begin
g := trunc(f div z[e]); {160}
f := f-(g*z[e]); {165}
if g = 1
then write(fout,LE[q],LE[q]) {170}
else write(fout,' ');
end; {for e}
write(fout,' '); {200, number of spaces between letters}
end; {for b}
writeln(fout); {220, ends each line of print}
end; {for d}
writeln(fout); writeln(fout); {230, 2 blank lines between each printed string}
1:
end; {while}
close(fout);
end.