diff options
author | Erich Eckner <git@eckner.net> | 2015-11-03 13:10:08 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2015-11-03 13:10:08 +0100 |
commit | 8e9852d03ef1247fd73c8a6d765d6459ee38b7bb (patch) | |
tree | de702cc29d9c463889bb73ba7c14585085f4e63e /fernbedienung.lpr | |
parent | ded9b69a25688e874ff3959126d206ef58fabbfc (diff) | |
download | Fernbedienung-8e9852d03ef1247fd73c8a6d765d6459ee38b7bb.tar.xz |
auf Checkoptions umgestellt
Diffstat (limited to 'fernbedienung.lpr')
-rw-r--r-- | fernbedienung.lpr | 78 |
1 files changed, 54 insertions, 24 deletions
diff --git a/fernbedienung.lpr b/fernbedienung.lpr index e47e7b1..e7a2412 100644 --- a/fernbedienung.lpr +++ b/fernbedienung.lpr @@ -8,36 +8,48 @@ uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} - Classes, lesethreadunit + Classes, SysUtils, CustApp, lesethreadunit { you can add units after this }, - sysutils, lowlevelunit, irdecoderunit, gitupdateunit; + lowlevelunit, irdecoderunit, gitupdateunit; -var - irDecoder: tIRDecoder; - inputDatei: string; - cnt: longint; - watte,debug: boolean; +type + + { tFernbedienung } + + tFernbedienung = class(tCustomApplication) + protected + procedure doRun; override; + private + irDecoder: tIRDecoder; + inputDatei: string; + watte,debug: boolean; + public + constructor create(theOwner: TComponent); override; + end; + + { tFernbedienung } + +procedure tFernbedienung.doRun; +var + errorMsg: String; begin - inputDatei:=''; - watte:=false; - debug:=false; - for cnt:=1 to paramcount do begin - if paramstr(cnt)='-W' then begin - watte:=true; - continue; - end; - if paramstr(cnt)='-D' then begin - debug:=true; - continue; - end; - if inputDatei<>'' then - raise exception.create('Mehr als eine inputDatei angegeben!'); - inputDatei:=paramstr(cnt); + // quick check parameters + errorMsg:=checkOptions('WdI:','Watte debug Input:'); + + if (errorMsg='') and + not hasOption('I','Input') then + errorMsg:='Erwarte Input: ''-I $Input'''; + + if errorMsg<>'' then begin + showException(exception.create(errorMsg)); + terminate; + exit; end; - if inputDatei='' then - raise exception.create('Keine inputDatei angegeben!'); + inputDatei:=getOptionValue('I','Input'); + watte:=hasOption('W','Watte'); + debug:=hasOption('d','debug'); irDecoder:=tIRDecoder.create(inputDatei,extractfilepath(paramstr(0))+'befehle.konf',watte,debug); @@ -49,5 +61,23 @@ begin until false; irDecoder.free; + // stop program loop + Terminate; +end; + + +constructor tFernbedienung.create(theOwner: TComponent); +begin + inherited Create(TheOwner); + stopOnException:=True; +end; + +var + application: tFernbedienung; +begin + application:=tFernbedienung.Create(nil); + application.title:='Fernbedienung'; + application.run; + application.free; end. |