home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PASCAL
/
MADTRB21.ZIP
/
BOXTEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-06-09
|
3KB
|
95 lines
{-----------------------------}
{ BOXTEST }
{ by Jeff Duntemann }
{ }
{ Character box draw demo }
{ }
{ Turbo Pascal V2.0 }
{ Last Update 1/4/85 }
{-----------------------------}
PROGRAM BOXTEST;
TYPE GRAFREC = RECORD
UL_CORNER,
UR_CORNER,
LL_CORNER,
LR_CORNER,
H_BAR,
V_BAR,
LINE_CROSS,
T_DOWN,
T_UP,
T_RIGHT,
T_LEFT : STRING[4]
END;
STRING80 = STRING[80];
VAR GRAFCHARS : GRAFREC;
X,Y : INTEGER;
WIDTH,HEIGHT : INTEGER;
PROCEDURE DEFINE_CHARS(VAR GRAFCHARS : GRAFREC);
BEGIN
WITH GRAFCHARS DO
BEGIN
UL_CORNER := CHR(201);
UR_CORNER := CHR(187);
LL_CORNER := CHR(200);
LR_CORNER := CHR(188);
H_BAR := CHR(205);
V_BAR := CHR(186);
LINE_CROSS := CHR(206);
T_DOWN := CHR(203);
T_UP := CHR(202);
T_RIGHT := CHR(185);
T_LEFT := CHR(204)
END
END;
PROCEDURE MAKE_BOX(X,Y,WIDTH,HEIGHT : INTEGER;
GRAFCHARS : GRAFREC);
VAR I,J : INTEGER;
BEGIN
IF X < 0 THEN X := (80-WIDTH) DIV 2; { Negative X centers box }
WITH GRAFCHARS DO
BEGIN { Draw top line }
GOTOXY(X,Y); WRITE(UL_CORNER);
FOR I := 3 TO WIDTH DO WRITE(H_BAR);
WRITE(UR_CORNER);
{ Draw bottom line }
GOTOXY(X,(Y+HEIGHT)-1); WRITE(LL_CORNER);
FOR I := 3 TO WIDTH DO WRITE(H_BAR);
WRITE(LR_CORNER);
{ Draw sides }
FOR I := 1 TO HEIGHT-2 DO
BEGIN
GOTOXY(X,Y+I); WRITE(V_BAR);
GOTOXY((X+WIDTH)-1,Y+I); WRITE(V_BAR)
END
END
END;
BEGIN
RANDOMIZE; { Seed the pseudorandom number generator }
CLRSCR; { Clear the entire screen }
DEFINE_CHARS(GRAFCHARS); { Go get box-draw characters for this machine }
WHILE NOT KEYPRESSED DO { Draw boxes until a key is pressed }
BEGIN
X := RANDOM(72); { Get a random X/Y for UL corner of box }
Y := RANDOM(21);
REPEAT WIDTH := RANDOM(80-72) UNTIL WIDTH > 1; { Get random height & }
REPEAT HEIGHT := RANDOM(25-Y) UNTIL HEIGHT > 1; { width to fit on CRT }
MAKE_BOX(X,Y,WIDTH,HEIGHT,GRAFCHARS); { and draw it! }
END
END.