home *** CD-ROM | disk | FTP | other *** search
- Unit XtraDos;
-
- {$F+}
-
- Interface
-
- Uses Dos,Crt;
-
- Type
- CallH = Object
- Procedure BoxText(Phrase : String; Row : Integer);
- Procedure EraseBox(Length, Row : Integer);
- Procedure DrawBox(c1,r1,c2,r2:Integer);
- Procedure CenterText(Phrase : String; Row : Integer);
- Procedure KeyPressLoop;
- Procedure CursorOff;
- Procedure CursorOn;
- Procedure DisplayTime(Column, Row : Integer);
- Function GetKey : Char;
- Function CheckDate(Arrive:String) : Boolean;
- Function Eight(Temp_Arrive:String) : String;
- Function GetYear(Arrive:String):Integer;
- Function LeadingZero(w: Word) : String;
- Function GetSelection(Pressed : Char) : Integer;
- Function GetDayOfWeek(Year:Integer):Integer;
- Function DayOfYear(Arrive:String):Integer;
- End;
-
- Implementation
-
- Procedure CallH.BoxText(Phrase : String; Row : Integer);
-
- Var
- Count,
- LPhrase,
- C1,C2,R1,R2,
- Center : Integer;
-
- Begin
- LPhrase:=Length(Phrase);
- Center:=40-(LPhrase Div 2);
- C1:=Center-2;
- C2:=(Center+LPhrase)+1;
- R1:=Row-1;
- R2:=Row+1;
- For Count:=c1 to c2 Do
- Begin
- GotoXY(count,r1);
- Write(Chr(205));
- GotoXY(count,r2);
- Write(Chr(205));
- End;
- For Count:=r1 to r2 Do
- Begin
- GotoXY(c1,count);
- Write(Chr(186));
- GotoXY(c2,count);
- Write(Chr(186));
- End;
- GotoXY(c1,r1);
- Write(Chr(201));
- GotoXY(c2,r2);
- Write(Chr(188));
- GotoXY(c1,r2);
- Write(Chr(200));
- GotoXY(c2,r1);
- Write(Chr(187));
- GotoXY(Center,Row);
- Write(Phrase);
- End;
-
- Procedure CallH.EraseBox(Length, Row : Integer);
-
- Var
- C1, C2, R1, R2,
- Count, Count2, Center : Integer;
-
- Begin
- Center:=40-(Length Div 2);
- C1:=Center-2;
- C2:=(Center+Length)+1;
- R1:=Row-1;
- R2:=Row+1;
- For Count2:=c1 to c2 Do
- Begin
- For Count:=r1 to r2 Do
- Begin
- GotoXY(Count2,Count);
- Write(' ');
- End;
- End;
- End;
-
- Procedure CallH.DrawBox(c1,r1,c2,r2:Integer);
-
- Var
- Count : Integer;
-
- Begin
-
- For Count:=c1 to c2 Do
- Begin
- GotoXY(count,r1);
- Write(Chr(205));
- GotoXY(count,r2);
- Write(Chr(205));
- End;
- For Count:=r1 to r2 Do
- Begin
- GotoXY(c1,count);
- Write(Chr(186));
- GotoXY(c2,count);
- Write(Chr(186));
- End;
- GotoXY(c1,r1);
- Write(Chr(201));
- GotoXY(c2,r2);
- Write(Chr(188));
- GotoXY(c1,r2);
- Write(Chr(200));
- GotoXY(c2,r1);
- Write(Chr(187));
- End;
-
- Procedure CallH.CenterText(Phrase : String; Row : Integer);
-
- Var
- Count,
- LPhrase,
- Center : Integer;
-
- Begin
- LPhrase:=Length(Phrase);
- Center:=40-(LPhrase Div 2);
- GotoXY(Center,Row);
- Write(Phrase);
- End;
-
-
-
- Procedure CallH.KeyPressLoop;
-
- Var
- K : Char;
-
- Begin
- Repeat
- K := ReadKey;
- Until K<>''
- End;
-
- Procedure CallH.CursorOff;
-
- Var
- Regs : Registers;
-
- Begin
- Regs.AH:=$01;
- Regs.CH:=$20;
- Regs.CL:=$20;
- Intr($10,Regs);
- End;
-
- Procedure CallH.CursorOn;
-
- Var
- Regs : Registers;
-
- Begin
- Regs.AH:=$01;
- Regs.CH:=$0;
- Regs.CL:=$7;
- Intr($10,Regs);
- End;
-
- Procedure CallH.DisplayTime(Column, Row : Integer);
-
- Const
-
- WMTH : Array[1..12] Of String[10] =('January','February','March','April','May',
- 'June','July','August','September','October',
- 'November','December');
-
- DayOWs : array [0..6] of String[9] = ('Sunday','Monday','Tuesday', 'Wednesday',
- 'Thursday','Friday','Saturday');
-
-
- var
- T, C, d2, y2,
- Z,x,y : String[20];
- d : String[40];
- A : string[2];
- yr,mth,dy,dow,
- h, m, s, hund : Word;
-
- begin
- GetTime(h,m,s,hund);
- If h>12 then
- begin
- h:=h-12;
- A:='pm';
- end
- else
- a:='am';
- z:=LeadingZero(m);
- c:=LeadingZero(s);
- str(h,x);
- If h<10 Then
- T:=' '+x+':'
- Else
- t:=x+':';
- Y:=t+z+':'+c+a;
- GotoXY(58,24);
- Write(y);
- GetDate(yr,mth,dy,dow);
- str(dy,d2);
- str(yr,y2);
- d:=DayOWS[Dow]+', '+WMTH[mth]+' '+d2+', '+y2;
- GotoXY(Column, Row);
- Write(d);
- end;
-
- Function CallH.GetKey : Char;
-
- Var
- K : Char;
-
- Begin
- Repeat
- K := ReadKey;
- Until K<>'';
- GetKey:=K;
- End;
-
- Function CallH.CheckDate(Arrive:String) : Boolean;
-
- Type
-
- DaysPerMonth = Array[1..12] Of Integer;
-
- Var
- Leap : Boolean;
- DPM : DaysPerMonth;
- L,
- D,
- Code,
- Wm,
- Wd,
- Month,
- Day,
- Year : Integer;
- Mth,
- Dy,
- Yr : String;
-
- Begin
-
- DPM[1]:=31;
- DPM[2]:=28;
- DPM[3]:=31;
- DPM[4]:=30;
- DPM[5]:=31;
- DPM[6]:=30;
- DPM[7]:=31;
- DPM[8]:=31;
- DPM[9]:=30;
- DPM[10]:=31;
- DPM[11]:=30;
- DPM[12]:=31;
-
- CheckDate:=TRUE;
- Leap:=FALSE;
- Mth:='';
- Dy:='';
- Yr:='';
- L:=Length(Arrive);
- Wm:=Pos('/',Arrive);
- For D:=Wm To L Do
- Begin
- If Arrive[D]='/' Then
- Wd:=D
- End;
- For D:=1 To (Wm-1) Do
- Begin
- Mth:=Mth+Arrive[D];
- End;
- For D:=(Wm+1) To (Wd-1) Do
- Begin
- Dy:=Dy+Arrive[D];
- End;
- For D:=Wd+1 To L Do
- Begin
- Yr:=Yr+Arrive[D]
- End;
- Val(Mth,Month,Code);
- Val(Dy,Day,Code);
- Val(Yr,Year,Code);
- If (Year/4) = (Year Div 4) Then
- Leap:=TRUE;
- If ((Month>12) Or (Month<1)) Or ((Day<1) Or (Day>31)) Then
- CheckDate:=FALSE;
-
- If Day>DPM[Month] Then
- CheckDate:=FALSE;
-
- If ((Month=2) And (Leap)) And (Day=29) Then
- CheckDate:=TRUE;
- End;
-
-
- Function CallH.Eight(Temp_Arrive : String ) : String;
-
- Var
- C, L : Integer;
- ND, NM : String[2];
- DD,MM,YY : String[3];
-
- Begin
-
- DD:=Temp_Arrive[1]+Temp_Arrive[2];
- MM:=Temp_Arrive[3]+Temp_Arrive[4]+Temp_Arrive[5];
- YY:=Temp_Arrive[(Length(Temp_Arrive)-1)]+Temp_Arrive[(Length(Temp_Arrive))];
- If DD[2]='/' Then ND:='0'+DD[1] Else ND:=DD;
-
- If ((MM[1]='/') And (MM[3]='/')) Then NM:='0'+MM[2];
- If ((MM[1]='/') And (MM[3]<>'/')) Then NM:=MM[2]+MM[3];
- If MM[2]='/' Then NM:='0'+MM[1];
- If ((MM[3]='/') And (MM[1]<>'/')) Then NM:=MM[1]+MM[2];
-
- Eight:=ND+'/'+NM+'/'+YY;
- End;
-
-
-
- Function CallH.GetYear(Arrive:String):Integer;
-
- Var
- D,
- L,
- Code,
- Year : Integer;
- Yr : String;
-
- Begin
- Yr:='';
- L:=Length(Arrive);
- For D:=(L-1) To L DO
- Yr:=Yr+Arrive[D];
- Val(Yr,Year,Code);
- GetYear:=Year
- End;
-
- Function CallH.LeadingZero(w : Word) : String;
- var
- s : String;
- begin
- Str(w:0,s);
- if Length(s) = 1 then
- s := '0' + s;
- LeadingZero := s;
- end;
-
- Function CallH.GetSelection(Pressed : Char) : Integer;
-
- Var
- RealKey : Real;
- Code : Integer;
-
- Begin
- Val(Pressed,RealKey,Code);
- If Code=0 Then
- GetSelection := Trunc(RealKey)
- End;
-
- Function CallH.GetDayOfWeek(Year:Integer):Integer;
-
- Var
- OldYear,
- OldMonth,
- OldDay,
- OldDOW,
- NewYear,
- NewMonth,
- NewDay,
- NewDOW : Word;
-
- Begin
- GetDate(OldYear,OldMonth,OldDay,OldDOW);
- Year:=Year+1900;
- SetDate(Year,1,1);
- GetDate(NewYear,NewMonth,NewDay,NewDOW);
- SetDate(OldYear,OldMonth,OldDay);
- GetDayOfWeek:=NewDOW;
- End;
-
- Function CallH.DayOfYear(Arrive:String):Integer;
-
- Var
- DPlus : Array[1..12] Of Integer;
- L,
- D, YearAdd,
- Code,
- Wm,
- Wd,
- Month,
- Day,
- Year : Integer;
- Mth,
- Dy,
- Yr : String;
-
- Begin
- Mth:='';
- Dy:='';
- Yr:='';
- L:=Length(Arrive);
- Wm:=Pos('/',Arrive);
- For D:=Wm To L Do
- Begin
- If Arrive[D]='/' Then
- Wd:=D
- End;
- For D:=1 To (Wm-1) Do
- Mth:=Mth+Arrive[D];
- For D:=(Wm+1) To (Wd-1) Do
- Dy:=Dy+Arrive[D];
- For D:=(Wd+1) To L Do
- Yr:=Yr+Arrive[D];
-
- Val(Mth,Month,Code);
- Val(Dy,Day,Code);
- Val(Yr,Year,Code);
- DPlus[1]:=0;
- DPlus[2]:=31;
- DPlus[3]:=59;
- DPlus[4]:=90;
- DPlus[5]:=120;
- DPlus[6]:=151;
- DPlus[7]:=181;
- DPlus[8]:=212;
- DPlus[9]:=242;
- DPlus[10]:=273;
- DPlus[11]:=303;
- DPlus[12]:=334;
- If ((Year/4) = Trunc(Year/4)) And (Month>2) Then Day:=Day+1;
- DayOfYear:=DPlus[Month]+Day;
- End;
-
-
- End.
-