home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 September
/
Chip_1999-09_cd.bin
/
internet
/
Jeremy
/
tp
/
downloads
/
aplikace.pas
next >
Wrap
Pascal/Delphi Source File
|
1999-08-03
|
8KB
|
303 lines
Unit Aplikace;
interface
type AppData = record
Jmeno,
Verze,
Datum,
Autor,
Cislo: string;
end;
var AFiles: array [1..20] of string;
ARunOK: boolean;
Direct: word;
const
ARMode=true;
ANMode=false;
AContinue = 1;
AQuit = 2;
AReboot = 3;
AShell = 4;
CloseQ = true;
CloseN = false;
procedure InitApplication(A:AppData; ATypMode: boolean);
function CloseApplication(Typ: boolean): word;
procedure AReadData(AJmeno,AVerze,ADatum,AAutor,ACislo: string; Var B:AppData);
implementation
uses crt,dos,savewind,csmon,vstupy,okna;
var
ADeskB,ADeskW,ADeskG,ATitle,ADefault,AButton: byte;
boxscreen: pbuf;
const
AFCount: byte = 0;
AWidth: byte = 0;
var
dosscreen, appscreen:pbuf;
dosx, dosy, dosmode: byte;
DirInfo: SearchRec;
Amode: boolean;
AChar: char;
AName: string;
Aattr: byte;
function GetTextMode: byte;
var m: byte absolute $0000:$0449;
begin
GetTextMode:=m;
end;
procedure CenterEditData(A: AppData);
var Q: byte;
I: integer;
begin
Q:=0;
Q:=Ord(A.Jmeno[0]);
if Q<Ord(A.Verze[0]) then Q:=Ord(A.Verze[0]);
if Q<Ord(A.Datum[0]) then Q:=Ord(A.Datum[0]);
if Q<Ord(A.Autor[0]) then Q:=Ord(A.Autor[0]);
if Q<Ord(A.Cislo[0]) then Q:=Ord(A.Cislo[0]);
AWidth:=Q;
for I:=1 to (AWidth-Length(A.Jmeno)) div 2 do
A.Jmeno:=concat(' ',A.Jmeno);
for I:=1 to (AWidth-Length(A.Verze)) div 2 do
A.Verze:=concat(' ',A.Verze);
for I:=1 to (AWidth-Length(A.Datum)) div 2 do
A.Datum:=concat(' ',A.Datum);
for I:=1 to (AWidth-Length(A.Autor)) div 2 do
A.Autor:=concat(' ',A.Autor);
for I:=1 to (AWidth-Length(A.Cislo)) div 2 do
A.Cislo:=concat(' ',A.Cislo);
end;
procedure ADeskTop(Name: string);
var I: byte;
begin
window(1,1,80,25);
textattr:=ADeskW;
clrscr;
gotoxy(2,1); write('┌');
for I:=3 to 78 do
begin
gotoxy(i,1);
write('─');
end;
textattr:=ADeskB;
gotoxy(79,1); write('┐');
textattr:=ADeskW;
for I:=2 to 24 do
begin
gotoxy(2,i);
write('│');
end;
gotoxy(2,25);
write('└');
textattr:=ADeskB;
for I:=2 to 24 do
begin
gotoxy(79,i);
write('│');
end;
for I:=3 to 78 do
begin
gotoxy(i,25);
write('─');
end;
write('┘');
gotoxy(3,22); textattr:=ADeskB; write('┌');
for I:=4 to 77 do
begin
gotoxy(i,22);
write('─');
end;
gotoxy(3,23); write('│');
gotoxy(3,24); write('└');
gotoxy(78,22); textattr:=ADeskW; write('┐');
for I:=4 to 77 do
begin
gotoxy(i,24);
write('─');
end;
write('┘');
gotoxy(78,23); write('│');
textattr:=ATitle;
gotoxy(39-(Length(Name) div 2),1);
write(' ',Name,' ');
end;
procedure EntryBox(B: AppData);
var I: integer;
a,c: integer;
begin
CenterEditData(b);
{savewin(39-(AWidth div 2),8,39-(Awidth div 2)+AWidth+1,18,boxscreen);}
textattr:=ADeskG;
savewin(3,8,77,18,boxscreen);
gotoxy(39-(AWidth div 2),8);
textattr:=ADeskB;
write('┌');
for I:=39-(Awidth div 2)+1 to 39-(AWidth div 2)+AWidth do
begin
gotoxy(i,8);
write('─');
end;
textattr:=ADeskW;
gotoxy(39-(AWidth div 2)+AWidth+1,8);
write('┐');
textattr:=ADeskB;
for I:=9 to 17 do
begin
gotoxy(39-(AWidth div 2),i);
write('│');
end;
textattr:=ADeskW;
for I:=9 to 17 do
begin
gotoxy((39-AWidth div 2)+AWidth+1,i);
write('│');
end;
gotoxy(39-(Awidth div 2),18);
textattr:=ADeskB;
write('└');
textattr:=ADeskW;
for I:=39-(AWidth div 2)+1 to 39-(AWidth div 2)+Awidth do
begin
gotoxy(i,18);
write('─');
end;
write('┘');
a:=(AWidth div 2)+(AWidth mod 2);
textattr:=ADeskG;
gotoxy(39-(Awidth div 2)+1+(Awidth-(Length(B.Jmeno) div 2))-a,9); write(B.Jmeno);
gotoxy(39-(Awidth div 2)+1+(Awidth-(Length(B.verze) div 2))-a,10); write(B.Verze);
gotoxy(39-(Awidth div 2)+1+(Awidth-(Length(B.datum) div 2))-a,11); write(B.Datum);
gotoxy(39-(Awidth div 2)+1,12);
for I:=1 to Awidth do write(' ');
gotoxy(39-(Awidth div 2)+1+(Awidth-(Length(B.autor) div 2))-a,13); write(B.Autor);
gotoxy(39-(Awidth div 2)+1+(Awidth-(Length(B.cislo) div 2))-a,14); write(B.Cislo);
gotoxy(38,16);
textattr:=AButton;
write(' OK ');
textattr:=ADeskB;
gotoxy(39,17); write('▀▀▀▀');
gotoxy(42,16); write('▄');
gotoxy(4,23);
textattr:=ADeskG;
write(' Vítejte v aplikaci ...');
getkey;
{restorewin(39-(AWidth div 2),8,39-(Awidth div 2)+AWidth+1,18,boxscreen);}
restorewin(3,8,77,18,boxscreen);
end;
procedure AReadData(AJmeno,AVerze,ADatum,AAutor,ACislo: string; Var B:AppData);
begin
B.Jmeno:=AJmeno;
B.Verze:=AVerze;
B.Datum:=ADatum;
B.Autor:=AAutor;
B.Cislo:=ACislo;
end;
function ControlFiles: boolean;
var I: integer;
begin
for I:=1 to AFCount do
begin
FindFirst(AFiles[i],Archive,DirInfo);
if doserror<>0 then
begin
ControlFiles:=false;
exit;
end;
end;
ControlFiles:=true;
end;
procedure NastavBlikani(Blik : Boolean);
var Reg : Registers;
begin
Reg.AH := $0010;
Reg.AL := $0003;
If Blik then Reg.BL := 1 else Reg.BL := 0;
Intr($10, Reg);
end;
function CloseApplication(Typ: boolean): word;
var I,J: integer;
akce: word;
vseg: word;
w: word;
begin
savewin(1,1,80,25,appscreen);
textattr:=ADefault;
gotoxy(4,23); write(' Ukonçení práce s aplikací ... ');
window(1,1,80,25);
textattr:=16*black+white;
lowvideo;
clrscr;
if AMode then textmode(dosmode);
obnovkursor;
UnLoadChar;
restorewin(1,1,80,25,dosscreen);
gotoxy(dosx,dosy);
NastavBarvu(CtiPaletu(6),Stand[6]);
NastavBlikani(true);
ARunOK:=false;
end;
procedure InitApplication(A:AppData;ATypMode: boolean);
begin
dosx:=wherex;
dosy:=wherey;
dosmode:=getTextMode;
Amode:=ATypMode;
AName:=A.Jmeno;
savewin(1,1,80,25,dosscreen);
skryjkursor;
LoadChar;
NastavBlikani(false);
ADeskTop(AName);
EntryBox(A);
if controlfiles=false then
begin
write(#7);
CloseApplication(CloseN);
end
else ARunOK:=true;
end;
BEGIN
checkbreak:=false;
if GetTextMode=7 then {barvy pro Hercules}
begin
ADeskB:=16*lightgray+black;
ADeskW:=16*lightgray+black;
ADeskG:=16*lightgray+black;
ATitle:=16*lightgray+black;
ADefault:=16*black+lightgray;
AButton:=16*black+white;
end
else
begin {barvy pro barevny EGA/VGA}
ADeskB:=16*lightgray+black;
ADeskW:=16*lightgray+white;
ADeskG:=16*lightgray+darkgray;
ATitle:=16*lightgray+blue;
ADefault:=16*lightgray+darkgray;
AButton:=16*blue+yellow;
end;
END.