Skip to content

Commit

Permalink
pas
Browse files Browse the repository at this point in the history
  • Loading branch information
Areso committed May 9, 2016
1 parent 19f4098 commit 6c16645
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions project1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
program project1;

{$mode objfpc}{$H+}

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

type

{ TMyApplication }

TMyApplication = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;

{ TMyApplication }

procedure TMyApplication.DoRun;
var
ErrorMsg: String;
i: integer;
sum: int64;
time1,time2, time3:TDateTime;
HH, MM, SS, MS: Word;
begin
// quick check parameters
ErrorMsg:=CheckOptions('h','help');
if ErrorMsg<>'' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;

// parse parameters
if HasOption('h','help') then begin
WriteHelp;
Terminate;
Exit;
end;

{ add your program here }
i:=0;
sum:=0;
time1 := Now();
for i:=0 to 999999 do
begin
sum := sum + i;
end;
time2 := Now();
time3 := time2 - time1;
DecodeTime(Time3, HH, MM, SS, MS);
writeln (SS+MS);
writeln (sum);
// stop program loop
Terminate;
end;

constructor TMyApplication.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;

destructor TMyApplication.Destroy;
begin
inherited Destroy;
end;

procedure TMyApplication.WriteHelp;
begin
{ add your help code here }
writeln('Usage: ',ExeName,' -h');
end;

var
Application: TMyApplication;
begin
Application:=TMyApplication.Create(nil);
Application.Title:='My Application';
Application.Run;
Application.Free;
end.

0 comments on commit 6c16645

Please sign in to comment.