Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program ZP;
- {$mode objfpc}{$H+}
- uses
- {$IFDEF UNIX}
- cthreads,
- {$ENDIF}
- Classes, SysUtils, crt, 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 }
- //global variable
- var
- i, j, sum, total: integer;
- s: string;
- procedure TMyApplication.DoRun;
- var
- ErrorMsg: String;
- 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;
- { body }
- textColor($02);
- write('Zephio Test', #13#10, 'Segitiga dengan jumlah', #13#10, '=======================================', #13#10);
- textColor($06);
- i := 0;
- j := 0;
- s := '';
- sum := 0;
- total := 0;
- //repeat
- while (i <= 10) do
- begin
- i := i + 1;
- s := s + IntToStr(j);
- //WriteLn(i, '. ', s ,chr($20), '[', sum, ']');
- writeln(Format('No: %.*d Sum: [%.*d] pattern: %s', [2, i, 2, sum, s]));
- total := total + sum;
- sum := sum + i;
- inc(j);
- end;
- //until i = 10;
- textcolor($07);
- writeln('=======================================', #13#10, 'Total: ', total);
- while true do
- sleep(100);
- // 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:='Zephio Test';
- Application.Run;
- Application.Free;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement