On Wed, 16 Jun 2021 12:08:26 +0200 (CEST), Michael Van Canneyt via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:

>FPC/lazarus tell you which units are unused, and in the Lazarus IDE you can 
>use the
>quick actions of the message dialog to quickly remove all unused units.
>I use it all the time.

Thanks, I will have a look and see what happens if you tell me where in Lazarus
to look.

My use case here is that I created a Windows version of Linux "uptime" by
starting in Lazarus with a new Project and selecting Program.
The resulting program looks like this:

program uptime;
//Uptime shows the elapsed time as days-hours-minutes-secods since system start
{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes, SysUtils
  { you can add units after this };

function FormatUpTime(Tdiff: QWord): string;
var
  t, d, h, m, s: integer;
begin
  t := Tdiff div 1000; //To get seconds
  s := t mod 60;
  m := (t div 60) mod 60;
  h := (t div 3600) mod 24;
  d := (t div 86400);
  if d > 0 then
    Result := Format('%d %.2d:%.2d:%2d',[d, h, m, s])
  else
    Result := Format('%.2d:%.2d:%2d',[h, m, s]);
end;

begin
  writeln(FormatUptime(GetTickCount64));
end.

I had to add SysUtils to make it work but Lazarus put Classes in there by
itself.
Since the final binary size after using strip -s on the exe file is 271 kb it
seems a bit big!
Or is there a lot behind the scenes I have missed?

I see many command line utilities (not written by me) that are *much* smaller
and still do much more....


-- 
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to