Kód: Vybrať všetko
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;
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 }
// 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;
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
begin
Application:=TMyApplication.Create(nil);
Application.Title:='My Application';
Application.Run;
Application.Free;
end.
toto je podprogram v inom súbore
Kód: Vybrať všetko
unit myprogram1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Label1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.Label1Click(Sender: TObject);
begin
end;
initialization
{$I myprogram1.lrs}
end.
Kód: Vybrať všetko
windres: can't open file `project1.manifest': No such file or directory
Hint: Start of reading config file c:\lazarus\fpc\2.2.4\bin\i386-win32\fpc.cfg
Hint: End of reading config file c:\lazarus\fpc\2.2.4\bin\i386-win32\fpc.cfg
Free Pascal Compiler version 2.2.4 [2009/10/25] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Win32 for i386
Compiling C:\Users\Nepta\AppData\Local\Temp\project1.lpr
Compiling resource C:\Users\Nepta\AppData\Local\Temp\project1.rc
c:\lazarus\fpc\2.2.4\bin\i386-win32\windres.exe: can't open file `project1.manifest': No such file or directory
project1.lpr(79,1) Error: Error while linking
project1.lpr(79,1) Fatal: There were 1 errors compiling module, stopping