From df39e91c2ceba6bc3595e9b718bf513599e6fab7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 24 Sep 2014 13:39:31 +0200 Subject: shell-environment-Variablen (abrufbar über ${Name}) einfache Vergleiche als Schalter (? a = b : Befehl) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ROM.lpr | 45 +++++++++++++++------------- ROM.lps | 98 ++++++++++++++++++++++++++++++------------------------------- romunit.pas | 14 +++++++++ 3 files changed, 88 insertions(+), 69 deletions(-) diff --git a/ROM.lpr b/ROM.lpr index 1249b26..98ead8c 100644 --- a/ROM.lpr +++ b/ROM.lpr @@ -12,12 +12,12 @@ uses { you can add units after this }, SysUtils,ROMunit, mathunit, Math; -var inPulsO,inPuls,refPulsO,refPuls,surTraj,cRefPuls: tExtPointArray; - smooth,betaSmooth: longint; - tmax,wmax,absShift,betaBound: extended; - force,fourier: boolean; - f: textfile; - s,lpicIn,rohIn,rohRef,outIn,outRef,outRefC,outSur: string; +var inPulsO,inPuls,refPulsO,refPuls,surTraj,cRefPuls: tExtPointArray; + smooth,betaSmooth: longint; + tmax,wmax,absShift,betaBound: extended; + force,fourier: boolean; + f: textfile; + s,t,u,lpicIn,rohIn,rohRef,outIn,outRef,outRefC,outSur: string; //const Verwendung='Verwendung: ROM ($Einfallspuls_Datei $Ausfallspuls_Datei)/(- $trace-Datei-Prefix) $output_inPuls $output_refPuls $output_Trajektorie $output_cRefPuls '+ // '[-s/--smooth $n] [-f/--force] [-t/--tmax $t] [-w/--wmax $w] [-F/--FFT] [-d/--dt $dt]'; @@ -47,10 +47,22 @@ begin reset(f); while not eof(f) do begin readln(f,s); + s:=shellSubst(s); if pos('#',s)>0 then delete(s,pos('#',s),length(s)); s:=trim(s); if s='' then continue; + if pos('?',s)=1 then begin + delete(s,1,1); + t:=trim(leftStr(s,pos('=',s)-1)); + delete(s,1,pos('=',s)); + u:=trim(leftStr(s,pos(':',s)-1)); + delete(s,1,pos(':',s)); + s:=trim(s); + if t<>u then + continue; + end; + if s='mit Gewalt' then begin force:=true; continue; @@ -113,44 +125,37 @@ begin end; if pos('lpic-Quelle:',s)=1 then begin delete(s,1,pos(':',s)); - s:=trim(s); - lpicIn:=s; + lpicIn:=trim(s); continue; end; if pos('in-Quelle:',s)=1 then begin delete(s,1,pos(':',s)); - s:=trim(s); - rohIn:=s; + rohIn:=trim(s); continue; end; if pos('reflex-Quelle:',s)=1 then begin delete(s,1,pos(':',s)); - s:=trim(s); - rohRef:=s; + rohRef:=trim(s); continue; end; if pos('in-Ziel:',s)=1 then begin delete(s,1,pos(':',s)); - s:=trim(s); - outIn:=s; + outIn:=trim(s); continue; end; if pos('reflex-Ziel:',s)=1 then begin delete(s,1,pos(':',s)); - s:=trim(s); - outRef:=s; + outRef:=trim(s); continue; end; if pos('reflex-Approx-Ziel:',s)=1 then begin delete(s,1,pos(':',s)); - s:=trim(s); - outRefC:=s; + outRefC:=trim(s); continue; end; if pos('trajektorie-Ziel:',s)=1 then begin delete(s,1,pos(':',s)); - s:=trim(s); - outSur:=s; + outSur:=trim(s); continue; end; Fehler('Unbekannter Parameter '''+s+''' in Inputdatei '''+paramstr(1)+'''!'); diff --git a/ROM.lps b/ROM.lps index 089957b..6c4702e 100644 --- a/ROM.lps +++ b/ROM.lps @@ -11,8 +11,8 @@ - - + + @@ -22,9 +22,9 @@ - - - + + + @@ -34,7 +34,7 @@ - + @@ -46,123 +46,123 @@ - + - + - + - + - + - + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/romunit.pas b/romunit.pas index 8d48b62..5e1bf79 100644 --- a/romunit.pas +++ b/romunit.pas @@ -30,6 +30,7 @@ procedure fft(var dat: tExtPointArray); procedure interpoliere(var dat: tExtPointArray); procedure normiere(var dat: tExtPointArray); procedure berechneRefPuls(inPuls,surTraj: tExtPointArray; betaGlaette: longint; betaBound: extended; out cRefPuls: tExtPointArray); +function shellSubst(s: string): string; type tSortThread = class(tThread) @@ -1015,6 +1016,19 @@ begin setlength(cRefPuls,anz); end; +function shellSubst(s: string): string; +var name: string; +begin + result:=s; + while pos('${',result)>0 do begin + s:=leftStr(result,pos('${',result)-1); + delete(result,1,pos('${',result)-1+length('${')); + name:=leftStr(result,pos('}',result)-1); + delete(result,1,length(name+'}')); + result:=s+GetEnvironmentVariable(name)+result; + end; +end; + // tSortThread ***************************************************************** constructor tSortThread.create(pd: pTExtPointArray; sta, sto: longint); -- cgit v1.2.3-70-g09d2