Matnli darchalar
Darcha, Sound, NoSound, Delay
CRT moduli dastur ishi davomida axborotni ekranga chikarish uchu n ekrandan tula emas, kisman foydalanish imkonini beradi Ekranning bu kismini darcha deb ataladi. Darchananing ulchovi foydalanuvchi tomonidan aniklanadi, lekin uning ulchovi ekran ulchovidan ortik bulmasligi kerak.Darchalarni tashkil kilish uchun Turbo-Pascal tilida Window(X1,Y1,X2,Y2) protsedurasidan foydalaniladi:
bu yerda X1, Y1 - yukori chap darcha burchak koordinatalari, X2, Y2 -lar pastki ung darcha burchak koordinatalari.. Tula ekran koordinatalari (1,1,80,25) ga teng minimal -bir katorga bir ustun.
Misol.
Window(1,1,80,25); { Darcha - tula ekran }
Window(19,7,59,16); { Ekran markazidagi darcha}
Window protsedurasi aktivlashgandan sung , CRT moduli joriy darcha ulchovlari kayd kilingan WindMin va WindMax uzgaruvchilarini ishga tushiradi.
Bu kiymatlardan darchalar sistemasini tashkillashda foydalanish mumkin. Masalan, joriy darchaning X- va Y- yukori ung burchak koordinatalarini aniklash uchun kuyidagi ifoda kullaniladi:
X := Lo(WindMin);
Y := Hi(WindMin);
Xuddi shu usulda joriy darchaning ung past burchak koordinatalarini aniklash mumkin. Writeln, Write, Readln, Read, Window, GoToXY, ClrScr, InsLine, DelLine, WhereX, WhereY protsedura va funsiyalari joriy darchaga nisbatan uzlariga birikrtirilgan xarakatlarni bajaradilar. Matn darchalari bilan ishlashni kuyidagi misolda kurib utamiz.
PROGRAM DemoRandomWindow;
USES Crt;
VAR
X, Y, I : byte;
BEGIN
NormVideo;
ClrScr;
FOR I:= 1 to 40 DO BEGIN
X:= Succ(Random(80));
Y:= Succ(Random(25));
Window(X,Y,X+Random(20),Y+Random(8));
TextBackGround(Random(8));
ClrScr;
Write('Darchaga chikarsh',^G, I);
Delay(300)
END;
END. { DemoRandomWindow }
Ushbu dastur 40 ta darchani generatsiya kiladi, chegara va fon tasodifiy tanlanadi.
Darchalar koordinatasini saklash uchun kuydagi strukturadan foydalaniladi:
TYPE
WinRecord = RECORD
XupLeft,
YupLeft,
XlowRight,
YupRight : byte;
END;
CONST
MaxWin = 10;
VAR
WinMas : array[1..MaxWin] of WinRecord;
Darchalar kupicha dasturlarda matnli axbortni skrollinlash (kayirish) uchun ishlatiladi. Bu protsessni InsLine va DelLine protseduralari yordamida xam bajarish mumkin.
PROGRAM DemoInsLine;
USES Crt;
VAR
I : byte;
BEGIN
Window(20,6,60,15);
ClrScr;
FOR I:= 1 TO 10 DO
Write('Darchaga chikish');
FOR I:= 1 TO 5 DO BEGIN
GoToXY(1,1);
InsLine;
Write('Katorni kushish');
Delay(500);
END;
END. { DemoInsLine }
Tovushli effektni xosil kilish uchun Turbo Pascal da CRT modulining Sound, NoSound va Delay standart funksiyalaridan foydalanamiz.
Sound(I: word) - shaxsiy kompyuterning tovush NoSound protsedurasi bilan olib tashlanmaguncha generatsiyalanib turadi.
NoSound - Sound protsedurasi bilan berilgan tovush rejimini olib tashlash..
Delay - bu protsedura tovush kancha vakt davom etishi mumkinligini aniklydi.
Misol.
BEGIN
Sound(500);
Delay(2000);
NoSound
END;
Bu misolda 555 Gs li tovush signali 2 s (2000 ms) davom etishi mumkin.
Do'stlaringiz bilan baham: |