home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ECO30603.ZIP / ECO30603.LZH / ECOLIBCS / DEMOS / S.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-12-18  |  1.7 KB  |  87 lines

  1. uses
  2.   dos
  3.  
  4.   ;
  5.  
  6.  
  7.  
  8.   function __num(nr: longint):string;
  9.   var temp: string;
  10.   begin
  11.     str(nr,temp); __num := temp;
  12.   end;
  13.  
  14.  
  15.  
  16.   function __power(x,y: integer): longint;
  17.   begin
  18.     if x>0 then
  19.     __power := round(exp(y*ln(x))) else if x<0 then
  20.       __power := -1 * (y mod 2) * round(exp(y*ln(x)));
  21.   end;
  22.  
  23.  
  24.   function __streal(nr: real; decs: byte): string;
  25.   var
  26.     tm1, tm2 : string;
  27.  
  28.   begin
  29.     tm1 := __num(trunc(nr));
  30.     tm2 := __num(
  31.       round(
  32.         (
  33.           nr - trunc(nr)
  34.         )
  35.         *
  36.         __power(10, decs)
  37.       )
  38.     );
  39.     __streal := tm1 + '.' + tm2;
  40.   end;
  41.  
  42.  
  43.  
  44.   function __pntstr(n: longint): string;
  45.   var
  46.     tmpnrstr,
  47.     tmpcvtstr   :  string;
  48.     tab, i,
  49.     len_numstr,
  50.     len_pnts    : longint; 
  51.  
  52.   begin
  53.     str(n, tmpnrstr); tab := 0;
  54.     len_numstr := length(tmpnrstr);
  55.     len_pnts := (len_numstr -1) div 3;
  56.     tmpcvtstr[0] := chr(len_numstr + len_pnts);
  57.  
  58.     tmpcvtstr[len_pnts +len_numstr -tab] := tmpnrstr[len_numstr];
  59.     for i := len_numstr-1 downto 1 do begin
  60.       if ((len_numstr -i) mod 3 =0) then begin
  61.         tmpcvtstr[len_pnts +i -tab] := '.'; inc(tab)
  62.       end;
  63.       tmpcvtstr[len_pnts +i -tab] := tmpnrstr[i];
  64.     end;
  65.     __pntstr := copy(tmpcvtstr, 1, len_numstr +len_pnts);
  66.   end;
  67.  
  68.  
  69. var
  70.   atri : searchrec;
  71.   tot  :      real;
  72.  
  73.  
  74. begin
  75.   tot := 0;
  76.   findfirst('*.*', anyfile, atri);
  77.   while doserror = 0 do begin
  78.     tot := tot + atri.size;
  79.     findnext(atri);
  80.   end;
  81.   write(' ');
  82.   if trunc((tot / 1024) / 1024) > 0 then write(
  83.     __streal(tot / 1024 / 1024, 1), ' Mb'
  84.   ) else if (tot / 1024 > 0) then write(trunc(tot / 1024), ' Kb');
  85.   writeln('   ', __pntstr(trunc(tot)));
  86. end.
  87.