* Example to demonstrate exit code forms in TCustomApplication

git-svn-id: trunk@42122 -
This commit is contained in:
michael 2019-05-25 15:52:33 +00:00
parent 77658b925b
commit f515c70a40
3 changed files with 34 additions and 0 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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)

View 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.