Program box;
uses Crt;
(*your procedure same as the procedure window in the crt unit...*)
procedure draw(x1,y1,x2,y2:integer);
(*local procedure line1*)
procedure line1(a,b,c,e:integer);
(*writes a - line to the screen*)
(*a and b are the starting position*)
begin
gotoxy(a,b);
while c <= e do begin
inc(c,1);
write(#196);
end;
end;(*end of line1*)
(*local procedure line2*)
(*this writes a | line to the screen*)
procedure line2(a,b,c,e:integer);
begin
while c <= e do begin
gotoxy(a,b);
write(#179);
inc(c,1);
inc(b);
end;
end;(*end of line2*)
begin
gotoxy(x1,y1);(*upper left corner of the box*)
write(#218);
gotoxy(x2,y1);(*upper right corner of the box*)
write(#191);
(*let's go back to the upper left corner*)
(*and concatenate the upper corners...*)
line1(x1+1,y1,x1,x2-2);
gotoxy(x2,y2);(*lower right corner of the box*)
write(#217);
gotoxy(x1,y2);(*lower left corner of the box*)
write(#192);
line1(x1+1,y2,x1,x2-2);(*concat the lower corners*)
line2(x1,y1+1,y1,y2-2);(*concat the left sides of the box*)
line2(x2,y1+1,y1,y2-2);(*and last,concat the right sides too*)
end;
begin
clrscr;
draw(5,1,20,20);
readln;
end.
Няма коментари:
Публикуване на коментар