home *** CD-ROM | disk | FTP | other *** search
- unit Pastools; { ¼«ñπ½∞ «Γ«ípáªÑ¡¿∩ ΓѬπΘÑú« óδ»«½¡Ñ¡¿∩ »p«úpá¼¼δ }
- { (æ) æÑ¼Ñ¡«ó é.ï. 1997 }
- {$F+}
- interface
- uses Dos, App, Objects, Drivers, Views;
-
- const
- rlRunningLine = $01; { ö½áú óδñáτ¿ íÑúπΘÑ⌐ ßΓp«¬¿ }
- rlMaxCount = $02; { ö½áú óδñáτ¿ ¼á¬ß¿¼á½∞¡«ú« º¡áτÑ¡¿∩ »ÑpѼѡ¡«⌐ µ¿¬½á }
- rlCurrCount = $04; { ö½áú óδñáτ¿ ΓѬπΘÑú« º¡áτÑ¡¿∩ »ÑpѼѡ¡«⌐ µ¿¬½á }
- rlPercent = $08; { ö½áú óδñáτ¿ ñ«½¿ »p«ΦÑñΦÑ⌐ «ípáí«Γ¬¿ }
- rlExecTime = $10; { ö½áú óδñáτ¿ ópѼѡ¿ «ípáí«Γ¬¿ }
- rlMemAvail = $20; { ö½áú óδñáτ¿ pẼÑpá ßó«í«ñ¡«⌐ »á¼∩Γ¿ }
- rlFullInf = $3F; { ö½áú óδñáτ¿ óßÑσ ß««íΘÑ¡¿⌐ }
- (*---------------------------------------------------------------------}
- { { Åα¿¼Ñα ¿ß»«½∞º«óá¡¿∩ ¼«ñπ½∩ } }
- { uses Pastools, StrBit16, ... }
- { ... }
- { var Xod_vyp : PRunningLine; { ÄíΩѬΓ, «Γ«íαáªáεΘ¿⌐ σ«ñ óδ»«½¡Ñ¡¿∩ } }
- { is_file : PBitFile; { êßσ«ñ¡δ⌐ í¿Γ«óδ⌐ »«Γ«¬ } }
- { ... }
- { begin }
- { ... }
- { is_file := New(PBitFile,Init(1,4096)); { ÄΓ¬αδΓ∞ í¿Γ«óδ⌐ Σá⌐½ } }
- { is_file^.OpenBitFile('aa.txt',btOpenRead); }
- { { éδóÑßΓ¿ »½«ßπ »α«úαÑßßá óδ»«½¡Ñ¡¿∩ «»Ñαᵿ¿ } }
- { New(Xod_vyp,Init(' ', is_file^.SizeOfFile,rlFullInf)); }
- { ... }
- { while is_file^.ReadStr(200) = btOK do begin }
- { Xod_vyp^.StatusDisplay(is_file^.NomTekBi); { Äí¡«ó¿Γ∞ ß«ßΓ«∩¡¿Ñ } }
- { ... }
- { end; }
- { ... }
- { Dispose(Xod_vyp,Done); { ôñ὿Γ∞ »«½«ßπ »α«úαÑßßá } }
- { is_file^.CloseBitFile; }
- { Dispose(is_file,Done); }
- {---------------------------------------------------------------------*)
- type
- PRunningLine = ^TRunningLine;
- TRunningLine = object(TWindow)
- constructor Init(ATitle: string; MaxCount : Longint; AOptions:byte);
- constructor InitRect(R:Trect; ATitle: string;
- MaxCount : Longint; AOptions:byte);
- procedure StatusDisplay(CurrCount :Longint);
- private
- PInterior : PView;
- end;
- PMemoryTest = ^TMemoryTest;
- TMemoryTest = object { »p«óÑp¬á «ßó«í«ªñÑ¡¿∩ ÄÅ }
- constructor Init(ATitle: string);
- destructor Done;
- procedure ErrDisplay(Size:Longint);
- private
- MemAvailStart : Longint;
- ident : string[8];
- end;
-
- implementation
-
- type
- PRunningLineInterior = ^TRunningLineInterior;
- TRunningLineInterior = object(TView)
- constructor Init(RBounds:Trect; MaxCount : Longint; AOptions:byte);
- procedure Draw; virtual;
- procedure SetCurrentCount (CurrCount : Longint);
- private
- rlOptions : byte;
- CurrentCount : Longint;
- MaximumCount : Longint;
- Time : Longint; { ó ßѬπ¡ñáσ }
- end;
-
- { ------- TRunningLine ------------ }
- constructor TRunningLine.Init(ATitle: string;
- MaxCount : Longint; AOptions:byte);
- var
- R : Trect;
- nr,i : byte;
- begin
- nr := 0;
- for i := 0 to 5 do
- if (AOptions AND ($0001 shl i)) <> 0 then inc(nr);
- i := Length(ATitle);
- if i < 22 then i := 32 else inc(i,10);
- R.Assign(0,0,i,nr+3);
- R.Move((Desktop^.Size.X-R.B.X) div 2,(Desktop^.Size.Y-R.B.Y) div 2);
- InitRect(R,ATitle,MaxCount, AOptions);
- end; { TRunningLine.Init }
-
- constructor TRunningLine.InitRect(R:Trect; ATitle: string;
- MaxCount : Longint; AOptions:byte);
- begin
- TWindow.Init(R,ATitle,wnNoNumber);
- Options := Options and (NOT ofSelectable);
- GetExtent(R);
- R.Grow(-1,-1);
- PInterior := New(PRunningLineInterior,Init(R,MaxCount, AOptions));
- Insert(PInterior);
- DeskTop^.Insert(@Self);
- end; { TRunningLine.InitRect }
-
- procedure TRunningLine.StatusDisplay(CurrCount :Longint);
- var
- pRL : PRunningLineInterior absolute PInterior;
- begin
- pRL^.SetCurrentCount(CurrCount);
- pRL^.DrawView;
- end; { TRunningLine.StatusDisplay }
-
- { ------- TRunningLineInterior ------------ }
- constructor TRunningLineInterior.Init(RBounds:Trect;
- MaxCount : Longint; AOptions:byte);
- var h,m,s,s100 : word;
- begin
- TView.Init(RBounds);
- rlOptions := AOptions;
- CurrentCount := 0;
- MaximumCount := Abs(MaxCount);
- GetTime(h,m,s,s100);
- Time := h * 60 + m;
- Time := Time * 60 + s;
- end; { TRunningLineInterior.Init }
-
- procedure TRunningLineInterior.Draw;
- var cs : string;
-
- procedure FillTime;
- var h,m,s,s100 : word;
- et : Longint;
- Param : record h,m,s : Longint; end;
- begin
- GetTime(h,m,s,s100);
- et := h * 60 + m;
- et := et * 60 + s - Time;
- if et < 0 then Inc(et,24*60*60);
- With param do begin
- S := et mod 60;
- M := (et div 60) mod 60;
- H := et div 3600;
- end;
- FormatStr(cs,'%02d:%02d:%02d',Param);
- cs := ' épѼ∩ :' + cs;
- end;
-
- procedure CountToLine(Count:longint;ATitle:string);
- begin
- Str(Count:8,cs);
- Cs := ' '+ ATitle + ':' + Cs;
- end;
-
- const
- rlFirstLine = $80;
- rlMass : array [0..6] of byte =
- ( rlFirstLine, rlRunningLine, rlMaxCount, rlCurrCount,
- rlPercent, rlExecTime, rlMemAvail);
- var Percent,i,QCols : byte;
- VProc : real;
- Color : word;
- nr : integer;
- B : TDrawBuffer;
- begin
- if MaximumCount = 0 then Percent := 0
- else begin
- VProc := CurrentCount;
- VProc := VProc * 100 / MaximumCount;
- Percent := Trunc(VProc);
- end;
- qCols := Percent * (Size.X-2) div 100;
- Color := GetColor(1);
- nr := -1;
- for i := 0 to 6 do begin
- cs := '';
- case ((rlOptions OR rlFirstLine) AND rlMass[i]) of
- rlFirstLine : cs := ' ';
- rlRunningLine : begin
- while Length(cs) < qCols do Cs := Cs + #219;
- while Length(cs) < Size.X-2 do Cs := Cs + #177;
- cs := ' ' + cs + ' ';
- end;
- rlMaxCount : CountToLine(MaximumCount,' éßÑú« ');
- rlCurrCount : CountToLine(CurrentCount,' Äípáí«Γá¡« ');
- rlPercent : CountToLine(Percent ,' % ');
- rlExecTime : FillTime;
- rlMemAvail : begin
- Str((MemAvail div 1024):3,cs);
- cs := ' æó«í«ñ¡á∩ »á¼∩Γ∞: '+ cs +' èí'
- end
- end; { Case }
- if Length(cs) <> 0 then begin
- inc(nr); While Length(cs) < Size.X do Cs := Cs + ' ';
- MoveStr(B,cs,Color); WriteLine(0,nr,Size.X,1,B)
- end;
- end { µ¿¬½á }
- end; { TRunningLineInterior.Draw; }
-
- procedure TRunningLineInterior.SetCurrentCount (CurrCount : Longint);
- begin
- CurrentCount := Abs(CurrCount) mod ( MaximumCount + 1 )
- end; { TRunningLineInterior.SetCurrentCount }
-
- { ---------- TMemoryTest -------------- }
-
- constructor TMemoryTest.Init(ATitle: string);
- begin
- MemAvailStart := MemAvail;
- ident := ATitle;
- end;
-
- destructor TMemoryTest.Done;
- var i : longint;
- begin
- i := MemAvailStart - MemAvail;
- if i <> 0 then ErrDisplay(i);
- end;
-
- procedure TMemoryTest.ErrDisplay(Size:Longint);
- begin
- WriteLn(Ident + ': ¡Ñ «ßó«í«ªñÑ¡á ÄÅ pẼÑp«¼ (ó íá⌐Γáσ) = ',Size);
- WriteLn('ì᪼¿ΓÑ "Enter"');
- Readln;
- end;
-
- end.