Quellcode durchsuchen

* Example to demonstrate exit code forms in TCustomApplication

git-svn-id: trunk@42122 -
michael vor 6 Jahren
Ursprung
Commit
f515c70a40

+ 1 - 0
.gitattributes

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

+ 1 - 0
packages/fcl-base/examples/README.txt

@@ -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 - 0
packages/fcl-base/examples/testappexit.pp

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