| Previous | Table of Contents | Next |
Listing 5.41. A demonstration of text appearance procedures.
program fig41; uses crt;
{ Demonstration along with listing of equivalent constants }
type
string19 = string[19];
var
i: byte;
function returntextconstant(color: byte):string19;
var
rtrn: string19;
begin
rtrn := ;
if color >= 128 then
begin
rtrn := Blink+;
dec(color, 128);
end;
case color of
0: rtrn := rtrn + Black ;
1: rtrn := rtrn + Blue ;
2: rtrn := rtrn + Green ;
3: rtrn := rtrn + Cyan ;
4: rtrn := rtrn + Red ;
5: rtrn := rtrn + Magenta ;
6: rtrn := rtrn + Brown ;
7: rtrn := rtrn + LightGray ;
8: rtrn := rtrn + DarkGray ;
9: rtrn := rtrn + LightBlue ;
10: rtrn := rtrn + LightGreen ;
11: rtrn := rtrn + LightCyan ;
12: rtrn := rtrn + LightRed ;
13: rtrn := rtrn + LightMagenta ;
14: rtrn := rtrn + Yellow ;
15: rtrn := rtrn + White ;
end;
returntextconstant := rtrn;
end;
procedure writeblock(color:byte);
begin
write(#219:6,#219,#219,#219, - );
write(returntextconstant(color));
end;
procedure writescreenpage(start: byte);
var
i: byte;
begin
for i := start to start+15 do
begin
textcolor(i);
writeblock(i);
if (i+1) mod 2 = 0 then
begin writeln;writeln;end;
end;
end;
procedure textcolordemo;
begin
{ Does the 8 screens with backgrounds changed }
for i := 0 to 7 do
begin
textbackground(i);
clrscr;
textcolor(white);
writeln(Screen Demonstration: Text Background = ,
returntextconstant(i));
writeln;
writescreenpage(0);
readln;
end;
{ does blinking screen demo}
textcolor(white);
textbackground(black);
clrscr;
writeln(Screen Demonstration: Blinking Text);
writeln;
writescreenpage(128);
{ start from 128; textattribute + 128 is blink }
readln;
end;
procedure gotoxydemo;
begin
clrscr;
randomize;
textcolor(white);
writeln(Screen Positioning Demo: press a key when done);
repeat
textcolor(random(15)+1);
gotoxy(random(79)+1, random(23)+2);
write(#254);
delay(500);
gotoxy(wherex-1, wherey);
textcolor(black);
write(#216);
until keypressed;
textbackground(black);
end;
begin
textbackground(black);
writeln;
textcolordemo;
gotoxydemo;
clrscr;
textcolor(white);
clrscr;
writeln(Thanks for your time!);
end.
This section demonstrates the procedures and functions used to perform varied DOS-related capabilities in Turbo Pascal in a process-oriented illustration. Note that this includes executing another program, taking parameters from the command line for a program, listing files on the drive, confirming a files existence, and using Pascal equivalents to DOS-based functions that work on directories as well as files themselves. In addition, most, but not all, procedures and functions described here make use of the DOS unit. Assumed is a working knowledge of using the DOS operating system, but not an expert knowledge. Because of the somewhat limited scope of this document, not all procedures and functions are demonstrated.
| Previous | Table of Contents | Next |