mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-02-25 08:48:54 +01:00
* Example to demonstrate exit code forms in TCustomApplication
git-svn-id: trunk@42122 -
This commit is contained in:
parent
77658b925b
commit
f515c70a40
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1989,6 +1989,7 @@ packages/fcl-base/examples/stringl.pp svneol=native#text/plain
|
||||
packages/fcl-base/examples/tarmakercons.pas svneol=native#text/plain
|
||||
packages/fcl-base/examples/tarmakerconsgzip.pas svneol=native#text/plain
|
||||
packages/fcl-base/examples/testapp.pp svneol=native#text/plain
|
||||
packages/fcl-base/examples/testappexit.pp svneol=native#text/plain
|
||||
packages/fcl-base/examples/testbf.pp svneol=native#text/plain
|
||||
packages/fcl-base/examples/testbs.pp svneol=native#text/plain
|
||||
packages/fcl-base/examples/testcgi.html -text
|
||||
|
||||
@ -76,3 +76,4 @@ testtimer.pp Test for TFPTimer (MVC)
|
||||
testini.pp Test/Demo for inifiles, ReadSectionValues.
|
||||
contit.pp Test/Demo for iterators in contnr.pp
|
||||
csvbom.pp Test/Demo for BOM detection in CSV document. (needs databom.txt)
|
||||
testappexit.pp Test/Demo for TApplication exit code handling. (ExitCode and ExceptionExitcode)
|
||||
|
||||
32
packages/fcl-base/examples/testappexit.pp
Normal file
32
packages/fcl-base/examples/testappexit.pp
Normal file
@ -0,0 +1,32 @@
|
||||
program testappexit;
|
||||
|
||||
uses sysutils,custapp;
|
||||
|
||||
type
|
||||
TApplication = Class(TCustomApplication)
|
||||
Procedure DoRun; override;
|
||||
end;
|
||||
|
||||
Procedure TApplication.DoRun;
|
||||
|
||||
begin
|
||||
ExceptionExitCode:=9;
|
||||
If ParamStr(1)='-h' then
|
||||
Terminate(10)
|
||||
else if Paramstr(1)='-e' then
|
||||
Raise Exception.Create('Stopping with exception')
|
||||
else
|
||||
Writeln('Normal stop');
|
||||
Terminate;
|
||||
end;
|
||||
|
||||
begin
|
||||
With TApplication.Create(Nil) do
|
||||
try
|
||||
StopOnException:=True;
|
||||
Initialize;
|
||||
Run;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end.
|
||||
Loading…
Reference in New Issue
Block a user